Date: Dec 27, 2012 11:28 AM
Author: Quynh Tram Nghuyen Thi
Subject: 1 variable Derrivative of 2 D function...but Error..why??

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