Plotting multiple polynomials in matlab

Click For Summary
SUMMARY

This discussion focuses on plotting multiple polynomials in MATLAB, specifically using the fplot and plot functions. The user encountered issues when attempting to graph a polynomial, resulting in an incorrect representation of the function. The problem was identified as stemming from an insufficient number of points in the x vector, which led to a misleading graph. A recommendation was made to use a smaller step size for the x vector to achieve a more accurate plot.

PREREQUISITES
  • Familiarity with MATLAB programming environment
  • Understanding of polynomial functions and their graphical representation
  • Knowledge of MATLAB's fplot and plot functions
  • Ability to manipulate vectors and arrays in MATLAB
NEXT STEPS
  • Learn how to use MATLAB's fplot for automatic range and resolution adjustments
  • Explore vector manipulation techniques in MATLAB for better plotting
  • Investigate the use of linspace for generating evenly spaced points
  • Study advanced plotting techniques in MATLAB, such as combining multiple plots
USEFUL FOR

MATLAB users, data analysts, and engineers looking to visualize polynomial functions accurately and improve their plotting skills.

TaylorWatts
Messages
15
Reaction score
0
Ok, I can plot a single polynomial easy enough such as 3*(x^2)-1 using fplot, but I want to graph multiple polynomials.

When I try to use the plot it doesn't work even for one though. The graph is completely wrong.

ie I make a new m-file.

x = [-1:1];

y = 3*x.^2 - 1;

Then call the m-file in the command window.

Then plot(x,y,'-b')

But I get something resembling the absolute value of x instead :confused:
 
Physics news on Phys.org
There is only three points in your x vector! try a smaller step size.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K