数学建模社区-数学中国

标题: 求助,matlab second derivative approximation,导数逼近 [打印本页]

作者: splelvis    时间: 2010-2-19 05:39
标题: 求助,matlab second derivative approximation,导数逼近
clear all;
' A9 s2 u& T' z+ h8 tnx=50;
( A, V& d3 L3 E, s/ v' Wny=30;) }/ }2 O; D6 H9 p3 ?
hx=pi/nx;$ R  X; ]' V( Q
x=linspace(0,pi,nx+1);
4 u) W+ ^3 N/ P8 r2 v: @3 vy=linspace(0,pi,ny+1);
4 B) }& t- X0 u& ~) X" {' R, e( Hx_plus_h=x+hx.*ones(1,nx+1);
% U, ~* M' l) A6 Ax_minus_h=x-hx.*ones(1,nx+1);
7 ~6 Z9 x8 Y5 P5 s; }9 |for i=1:nx+1+ ]6 Q5 q. j: y" @
    for j=1:ny+11 Q) R" H7 Y$ c5 C3 r" G1 z2 y
        f_xx(j,i)=(f9(x_plus_h(i),y(j))-2*f9+f9(x_minus_h(i),y(j)))./(hx.^2);   %原式f(x+hx,y)-2f(x,y)+f(x-hx,y)./(hx^2)3 A  r. G$ J: r4 k7 S
    end;
# ?! X2 T% G% O  V5 F0 n' fend;+ {+ `' m- m) e
[xx,yy]=meshgrid(x,y);: ^- t, G  H$ i
surf(xx,yy,f_xx);
$ |* i* v2 p0 @1 Jtitle('partial derivative w.r.t.xx')1 }- r- ^9 b% c" p# ]3 F4 \/ p
  H- I8 T8 J4 M2 c, F; c

8 H% i" K4 V! J5 w/ P2 b* V" I另开一个f9文件,
9 @; }7 o2 ?' ]; z. a9 w+ b: C4 G/ Ofunction l=f9(x,y)
/ Z# b% f: ~9 a2 l- Al=exp(sin(x-y));
" K" H) ?! h9 q& f
3 J5 h7 D/ Q+ n4 d) e4 S2 p5 F4 f- ]! _$ s2 D; _
然后出来说错误了,, k% R5 V2 }* f
??? Input argument "x" is undefined.
8 I* ~9 }5 v, s: B4 t; U0 B0 A
- v+ a6 c, ?) t# O6 h: SError in ==> f9 at 2
, v- E! ]7 k2 u4 a/ d/ al=exp(sin(x-y));
* R& V; g( {2 @9 ~# t, X) L5 b7 yError in ==> partial_derivxx at 11
& I6 u, s7 e& k/ k' J        f_xx(j,i)=(f9(x_plus_h(i),y(j))-2*f9+f9(x_minus_h(i),y(j)))./(hx.^2);/ \5 @. w1 d& A8 P* M% ?

+ P7 \( i- U( l$ G! _. ~1 D各位要怎么改才对呢
作者: splelvis    时间: 2010-2-19 07:35
我自己找到了问题,f9应该是 f9(x(i),y(j))
作者: douglas8j    时间: 2010-2-19 07:35
abc~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
作者: splelvis    时间: 2010-2-19 07:49
不好意思,我也觉得自己太粗心了
作者: douglas8j    时间: 2010-2-19 07:59
henhaodeyipianwenzhang~~~~~~~~~~~~~~~`




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5