Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: 1 variable Derrivative of 2 D function...but Error..why??
Replies: 1   Last Post: Dec 27, 2012 8:15 PM

 Messages: [ Previous | Next ]
 Quynh Tram Nghuyen Thi Posts: 37 Registered: 4/13/12
1 variable Derrivative of 2 D function...but Error..why??
Posted: Dec 27, 2012 11:28 AM

Hello all,
very glad to see the room back.
May i start a question about DERRIVATIVE.
Problem: Compute DERRIVATIVE of FUNCTION U(x,y) by 1 variable x , domain 2D:RxR
I did:
m-file diff2.m:
function [du1]=diff2(Xi,Yi,Zi,X,Y,h)
if nargin<6; h=1e-4;end;
du1=(interp2(Xi,Yi,Zi,X+h)-interp2(Xi,Yi,Zi,X-h))/(2*h)

EXAMPLE on command window:
x=1:8;
>> y=1:4;
>> [u,v]=meshgrid(x,y)

z=peaks(u,v)

diff2(u,v,z,u,v)

===>>>ERROR:Error using ==> interp2 at 140
Wrong number of input arguments.

Error in ==> diff2 at 6
du1=(interp2(Xi,Yi,Zi,X+h)-interp2(Xi,Yi,Zi,X-h))/(2*h)
>>

WHY?? I DONT UNDERSTAND AT ALL.
ANYONE can give me any error in m-file??
Im waiting, all
thanks alot

Date Subject Author
12/27/12 Quynh Tram Nghuyen Thi
12/27/12 Roger Stafford