# m file failure?

Printable View

Show 40 post(s) from this thread on one page
Page 2 of 2 First 12
• April 26th 2010, 02:54 AM
CaptainBlack
Quote:

Originally Posted by ramdrop
I got a very nice plot, thanks, so I guess I do the same for the next part of the file?

As it happens you don't need to, at the command prompt now type:

Code:

```>>plot(x,(f(x+0.1)-f(x))/0.1,'r') >>plot(x,(f(x+0.01)-f(x))/0.01,'g') >>plot(x,(f(x+0.001)-f(x))/0.001,'b') >>plot(x,(f(x+0.0001)-f(x))/0.0001,'m')```
If you want them on the same plot you will need

Code:

`>>hold on`
before hand, (and sort out axes)

CB
• April 26th 2010, 03:10 AM
ramdrop
But what about the derivative? Im trying to differentiate the function, maybe its not being shown as well because the original is $e^x$

If it was for say, $x^2$:

Quote:

function [y]=f(x)
y=exp(x);

then...

Quote:

>>x=[-10:0.5:10]
>>y=f(x)
>>plot(x,y);
then, i want to plot the derivative, and approximate it... using the values of x = 0.01, 0.001.. .etc, so the fd(x) is needed.
• April 26th 2010, 03:56 AM
CaptainBlack
Quote:

Originally Posted by ramdrop
But what about the derivative? Im trying to differentiate the function, maybe its not being shown as well because the original is $e^x$

If it was for say, $x^2$:

then...

then, i want to plot the derivative, and approximate it... using the values of x = 0.01, 0.001.. .etc, so the fd(x) is needed.

Reread my last post

CB
• April 26th 2010, 04:15 AM
ramdrop
Thats my fault lol :P I under quite a bit of pressure today :f

But thanks, it works just like i wanted it too.

With the titles + axis labels, i just type them @ command promt or place them in the f file?
Show 40 post(s) from this thread on one page
Page 2 of 2 First 12