Subscript indices must either be real positive integers or logicals?
高手们快来帮我看看这个程序,改了好久都改不了错。程序如下:dufftingrk4.m(主程序)
L=testfun20091105(@testfun20091106,0,100,1000);
testfun20091105.m
function L=testfun20091105(F2,a,b,N)
ya=;
L=rk4(F2,a,b,ya,N);
rk4.m
function R=rk4(F,a,b,ya,N)
% y'=f(x,y);
% a,b 左右端点
% N 迭代步长
% h 为步长
% ya 为初值
h=(b-a)/N;
T=zeros(N+1,1);
Y=zeros(N+1,2);
T=a:h:b;
for j=1:N
k1=F(T(j),Y(j,1),Y(j,2));
k2=F(T(j)+h/2,Y(j,1)+Y(j,2)*h/2,Y(j,2)+k1*h/2);
k3=F(T(j)+h/2,Y(j,1)+Y(j,2)*h/2+k1*h*h/4,Y(j,2)+k2*h/2);
k4=F(T(j)+h,Y(j,1)+h*Y(j,2)+k2*h*h/2,Y(j,2)+h*k3);
Y(j+1,1)=Y(j,1)+h*Y(j,2)+h*h*(k1+k2+k3)/6;
Y(j+1,2)=Y(j,2)+h*(k1+2*k2+2*k3+k4)/6;
end
R=
testfun20091106.m
function dy=testfun20091106(t,y(1),y(2));
c=0.5;
F0=0.91175;
dy=;
出现的错误如下: Subscript indices must either be real positive integers or logicals.
Error in ==> C:\Documents and Settings\Administrator\桌面\rk4.m
On line 16==> k1=F(T(j),Y(j,1),Y(j,2));
Error in ==> C:\Documents and Settings\Administrator\桌面\testfun20091105.m
On line 4==> L=rk4(F2,a,b,ya,N);
Error in ==> C:\Documents and Settings\Administrator\桌面\dufftingrk4.m
On line 1==> L=testfun20091105(@testfun20091106,0,100,1000);
好像我的下标都是正整数啊
[ 本帖最后由 ChaChing 于 2009-11-20 22:17 编辑 ] T(j)+h/2是小数
页:
[1]