Quote (brigadier @ Apr 13 2013 11:08am)
I need to graph the function
F(x)=x^3 -3x^2 + 3x -1
But I thought matlab only graphs data not functions
Am I wrong?
Yes, well, here is what you can do.
You make a vector for x.
I.e. If you want x that go from -20 to -20 and you want to plot a point each like 0.01 (so it will look continuous).
Here is what you do.
x=[-20:0.01:20];
so you will have a vector full of x that will go in your desired bounds.
Now you have to manually evaluate the value of F.
So you do
F=x.^3 -3*x.^2 + 3*x -1 ;
don't forget the "." before the operator, because it will not work, because MATLAB will think you want to do vector multiplications (which is not the case, you want scalar).
And then, you just have to plot.
so
plot(x,F)
TLDR;
x=[-20:0.01:20];
F=x.^3 -3*x.^2 + 3*x -1 ;
plot(x,F)
This post was edited by Harmonium on Apr 13 2013 11:03am