Path: news.mathworks.com!not-for-mail
From: "Quynh Tram Nghuyen Thi" <lovelyeverything@yahoo.com.vn>
Newsgroups: comp.soft-sys.matlab
Subject: 1 variable Derrivative of 2 D function...but Error..why??
Date: Thu, 27 Dec 2012 16:28:07 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 29
Message-ID: <kbhsun$1k$1@newscl01ah.mathworks.com>
Reply-To: "Quynh Tram Nghuyen Thi" <lovelyeverything@yahoo.com.vn>
NNTP-Posting-Host: www-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1356625687 52 172.30.248.37 (27 Dec 2012 16:28:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 27 Dec 2012 16:28:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3434620
Xref: news.mathworks.com comp.soft-sys.matlab:785490

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