24小时热门版块排行榜    

查看: 758  |  回复: 4
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

wcnmaz

新虫 (小有名气)

[交流] MATLAB7.0出错了? 已有2人参与

y(i,6)=-178075801.6*y(i,4)*y(i,5)+490910.1296*y(i,3)*y(i,2)+1128974.05+7481.104004*sin(2.047t);
为什么MATLAB7.0程序运行到上面一行出错了?感觉也没什么错误啊
怎么改,谢谢了

ODE45_main文件:
clc;clear
tspan=[0,1];
y0=[0; 0;0;0;0];
[t,y]=ode45('ODE45_fun',tspan,y0);

[m,n]=size(y);
for i=1:m
    y(i,6)=-178075801.6*y(i,4)*y(i,5)+490910.1296*y(i,3)*y(i,2)+1128974.05+7481.104004*sin(2.047t);

end
data=[t,y];
save ODE45_data.txt data -ascii
subplot(2,3,1),plot(t,y(:,1)),title('y(1)')
Xlabel('t');Ylabel('y');
subplot(2,3,2),plot(t,y(:,2)),title('y(2)')
Xlabel('t');Ylabel('y');
subplot(2,3,3),plot(t,y(:,3)),title('y(3)')
Xlabel('t');Ylabel('y');
subplot(2,3,4),plot(t,y(:,4)),title('y(4)')
Xlabel('t');Ylabel('y');
subplot(2,3,5),plot(t,y(:,5)),title('y(5)')
Xlabel('t');Ylabel('y');
subplot(2,3,6),plot(t,y(:,6)),title('y(6)')
Xlabel('t');Ylabel('y');

grid on

ODE45_fun文件:
function  dy=ODE45_fun(t,y)
dy(1)=-1.918298553*y(3)*y(4)-121.6697369*y(5)*y(2)+0.006472085*y(2)*y(2)+15.25250926*y(5)*y(5)-0.518363603*sin(2.047t)+0.001124759;

dy(2)=0.007229182*y(5)*y(1)-0.013867729*y(3)-0.005151943*sin(2.047t)+33.43424564*y(4)*y(5)-0.092169794*y(3)*y(2)-0.698266828;

dy(3)=72.10986245*y(2)+0.52129529*y(4)*y(1)+0.025471074*y(3)+921.886526*y(4)/y(1)-0.47870471*y(4)+0.025471074*y(1)*t-0.38220722*cos(2.047t)-4.62279911;

dy(4)=-57.37263009*y(5)+0.001053501*y(3)*y(1)+20.28825016/y(1)-0.001053501*y(3)+0.064741605*y(4)+20.28825016*t-0.006201915*sin(2.047t)-3651.904822;
  
dy(5)=0.017284293*y(4)+0.00278644*y(1)*y(2)-0.551218454*y(2)*y(5)*y(5)+0.010839281*y(2)*y(2)*y(5)+0.020353114*cos(2.047t)+0.110594984;
dy=[dy(1);dy(2);dy(3);dy(4);dy(5)];
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

wcnmaz

新虫 (小有名气)

引用回帖:
2楼: Originally posted by amoroso_xmc at 2015-04-05 20:41:14
2.047和t之间漏了乘号*。
或者t不是一个标量?

谢谢回答了
2.047*t了,这一行还是出错啊
y(i,6)=-178075801.6*y(i,4)*y(i,5)+490910.1296*y(i,3)*y(i,2)+1128974.05+7481.104004*sin(2.047*t);


还有:[t,y]=ode45('ODE45_fun',tspan,y0); 没有错误吧


Warning: Failure at t=5.501826e-001【【【【y0=换不同的初始值,Failure at t不同】】】】. Unable to meet integration tolerances without reducing the step size below the
smallest value allowed (1.776357e-015) at time t.

the smallest value allowed怎么设置大一些?可以牺牲一些准确度


ODE45_main文件:
clc;clear
tspan=[0,180];
y0=[1e-5;1e-5;1e5;1e-5;1e-5];
[t,y]=ode45('ODE45_fun',tspan,y0);


[m,n]=size(y);
for i=1:m
y(i,6)=-178075801.6*y(i,4)*y(i,5)+490910.1296*y(i,3)*y


(i,2)+1128974.05+7481.104004*sin(2.047*t);

end
data=[t,y];
save ODE45_data.txt data -ascii
subplot(2,3,1),plot(t,y(:,1)),title('y(1)')
Xlabel('t');Ylabel('y');
subplot(2,3,2),plot(t,y(:,2)),title('y(2)')
Xlabel('t');Ylabel('y');
subplot(2,3,3),plot(t,y(:,3)),title('y(3)')
Xlabel('t');Ylabel('y');
subplot(2,3,4),plot(t,y(:,4)),title('y(4)')
Xlabel('t');Ylabel('y');
subplot(2,3,5),plot(t,y(:,5)),title('y(5)')
Xlabel('t');Ylabel('y');
subplot(2,3,6),plot(t,y(:,6)),title('y(6)')
Xlabel('t');Ylabel('y');
% plot(t,y(:,1),'bo',t,y(:,2),'rx',t,y(:,3),'gv',t,y(:,4),'r-');
grid on




ODE45_fun文件:
function dy=ODE45_fun(t,y)
dy(1)=-1.918298553*y(3)*y(4)-121.6697369*y(5)*y(2)+0.006472085*y(2)*y(2)+15.25250926*y(5)*y(5)-0.518363603*sin(2.047*t)+0.001124759;


dy(2)=0.007229182*y(5)*y(1)-0.013867729*y(3)-0.005151943*sin(2.047*t)+33.43424564*y(4)*y(5)-0.092169794*y(3)*y(2)-0.698266828;


dy(3)=72.10986245*y(2)+0.52129529*y(4)*y(1)+0.025471074*y(3)+921.886526*y(4)/y(1)-0.47870471*y(4)+0.025471074*y(1)*t-0.38220722*cos(2.047*t)-4.62279911;


dy(4)=-57.37263009*y(5)+0.001053501*y(3)*y(1)+20.28825016/y(1)-0.001053501*y(3)+0.064741605*y(4)+20.28825016*t-0.006201915*sin(2.047*t)-3651.904822;

dy(5)=0.017284293*y(4)+0.00278644*y(1)*y(2)-0.551218454*y(2)*y(5)*y(5)+0.010839281*y(2)*y(2)*y(5)+0.020353114*cos(2.047*t)+0.110594984;


dy=[dy(1);dy(2);dy(3);dy(4);dy(5)];
4楼2015-04-06 14:43:44
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 5 个回答

amoroso_xmc

新虫 (初入文坛)


小木虫: 金币+0.5, 给个红包,谢谢回帖
2.047和t之间漏了乘号*。
或者t不是一个标量?
2楼2015-04-05 20:41:14
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

wyjjf

新虫 (正式写手)


小木虫: 金币+0.5, 给个红包,谢谢回帖
引用回帖:
2楼: Originally posted by amoroso_xmc at 2015-04-05 20:41:14
2.047和t之间漏了乘号*。
或者t不是一个标量?

标量?
3楼2015-04-06 07:06:14
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

wcnmaz

新虫 (小有名气)

y(i,6)=-178075801.6*y(i,4)*y(i,5)+490910.1296*y(i,3)*y(i,2)+1128974.05+7481.104004*sin(2.047*t);
这一行应该没有错误了吧???
5楼2015-04-06 19:16:41
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见