[T,Y]=ode45(@rigid,[0 1],[rand(15,1)]);
plot(T,Y(:,1),'-',T,Y(:,2),'-.',T,Y(:,3),'.',T,Y(:,4),'-',T,Y(:,5),'-.',T,Y(:,6),'.',T,Y(:,7),'-',T,Y(:,8),'-.',T,Y(:,9),'.',T,Y(:,10),'-',T,Y(:,11),'-.',T,Y(:,12),'-.',T,Y(:,13),'.',T,Y(:,14),'-',T,Y(:,15),'.')
M文件:
function dy=rigid(t,y)
c=0.1;
Dy=rand(15,1);
A=[-2 1 1 0 0;
0 -2 1 1 0;
0 0 -2 0 0;
1 1 0 -2 0;
0 0 0 0 0];
for i=1:5
s1=0;
s2=0;
s3=0;
for j=1:5
s1=s1+A(i,j)*y(3*i-2);
s2=s2+A(i,j)*y(3*i-1);
s3=s3+A(i,j)*y(3*i);
end
Dy(3*i-2)= 10*y(3*i-1)-y(3*i-2)+c*s1;
Dy(3*i-1)= 28*y(3*i-2)-y(3*i-1)-y(3*i-2)*y(3*i)+c*s2;
Dy(3*i)= y(3*i-2)*y(3*i-1)-8/3*y(3*i)+c*s3;
end
运行后出现错误:
One or more output arguments not assigned during call to 'C:\MATLAB7\work\rigid.m (rigid)'.
Error in ==> funfun\private\odearguments at 110
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ==> ode45 at 173
[neq,tspan,ntspan,next,t0,tfinal,tdir,y0,f0,odeArgs,...
人气:267 ℃ 时间:2020-06-20 01:50:57
解答
function dy=rigid(t,y) 中是dy下面用的是Dy,不统一.
推荐
猜你喜欢
- 草什么,花什么,鸟什么,填动词
- 翻译中文He came across an old painting at his friend's house.
- 帮我做几个初2数学题.因式分解.
- 人民教育版初三下数学书 第二十六章勾股定理 7,在△ABC中,∠C=90° AB=10 (1) ∠A=30° 求BC,AC 谢
- 如果x大于0,x的平方的算数平方根一定等于x吗?如果x是任意一个数,x的平方的算数平方根等于什么数
- What class are ____ in? ——I an in Class Four
- 英语翻译
- 五年级120人出去秋游,租了3辆大客车,还需要租几辆大客车?小客车每辆可以坐5人,大客车限32人.