d2jsp
Log InRegister
d2jsp Forums > Off-Topic > General Chat > Homework Help > Help Matlab
Add Reply New Topic New Poll
Member
Posts: 38,211
Joined: Feb 16 2009
Gold: 7,823.69
Apr 13 2013 10: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?
Member
Posts: 38,211
Joined: Feb 16 2009
Gold: 7,823.69
Apr 13 2013 10:27am
Fuck I also need help changing my newtons approximation for roots matlab code to be able to be used for the secant approximation method if anyone can help with this ~500fg
Member
Posts: 13,090
Joined: Jun 13 2006
Gold: 0.00
Apr 13 2013 10:34am
i can do this. gimme the exact problem.
Member
Posts: 2,396
Joined: Jan 11 2010
Gold: 46.00
Apr 13 2013 11:03am
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
Member
Posts: 7,721
Joined: Oct 11 2008
Gold: 304.00
Apr 13 2013 03:47pm
Quote (brigadier @ Apr 13 2013 10:27am)
Fuck I also need help changing my newtons approximation for roots matlab code to be able to be used for the secant approximation method if anyone can help with this ~500fg


post code
Go Back To Homework Help Topic List
Add Reply New Topic New Poll