MATLAB Plotting multiple polynomials in matlab

Click For Summary
To graph multiple polynomials using MATLAB, the user is encountering issues with plotting a single polynomial correctly. The provided code snippet initializes a vector x with values from -1 to 1 and calculates y as 3*x.^2 - 1. However, the resulting plot does not reflect the expected polynomial shape, resembling the absolute value function instead. The discussion highlights that the limited number of points in the x vector (only three points) is likely causing the incorrect graph. A recommendation is made to use a smaller step size for the x vector to achieve a smoother and more accurate representation of the polynomial when plotted.
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
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K