clear all;(adsbygoogle = window.adsbygoogle || []).push({});

nx=50;

ny=30;

hx=pi/nx;

x=linspace(0,pi,nx+1);

y=linspace(0,pi,ny+1);

x_plus_h=x+hx.*ones(1,nx+1);

x_minus_h=x-hx.*ones(1,nx+1);

for i=1:nx+1

for j=1:ny+1

f_xx(j,i)=(f9(x_plus_h(i),y(j))-2*f9+f9(x_minus_h(i),y(j)))./(hx.^2);

end;

end;

[xx,yy]=meshgrid(x,y);

surf(xx,yy,f_xx);

title('partial derivative w.r.t.xx')

,

and the other new document,f9,

function l=f9(x,y)

l=exp(sin(x-y));

and then the system said have error,

??? Input argument "x" is undefined.

Error in ==> f9 at 2

l=exp(sin(x-y));

Error in ==> partial_derivxx at 11

f_xx(j,i)=(f9(x_plus_h(i),y(j))-2*f9+f9(x_minus_h(i),y(j)))./(hx.^2);

where should i corrected to make it work?

thanks

anyone can help

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab second derivative approximation

Loading...

Similar Threads - Matlab second derivative | Date |
---|---|

Second Derivative in Matlab | Jul 17, 2016 |

Matlab Second Derivative Ploting Problem | Feb 12, 2012 |

Help with Matlab solving second order differential equations | Oct 19, 2010 |

Second order system of differential equations in Matlab | Feb 25, 2008 |

Matlab Second Derivative Ploting Problem | Dec 5, 2004 |

**Physics Forums - The Fusion of Science and Community**