| 5 | 1/1 | 返回列表 |
| 查看: 816 | 回復(fù): 4 | |||
| 當(dāng)前只顯示滿足指定條件的回帖,點(diǎn)擊這里查看本話題的所有回帖 | |||
wcnmaz新蟲 (小有名氣)
|
[交流]
MATLAB7.0出錯(cuò)了? 已有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程序運(yùn)行到上面一行出錯(cuò)了?感覺也沒什么錯(cuò)誤啊 怎么改,謝謝了 ![]() 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)]; |
新蟲 (初入文壇)
新蟲 (小有名氣)
|
謝謝回答了 2.047*t了,這一行還是出錯(cuò)啊 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); 沒有錯(cuò)誤吧 Warning: Failure at t=5.501826e-001【【【【y0=換不同的初始值,F(xiàn)ailure 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怎么設(shè)置大一些?可以犧牲一些準(zhǔn)確度 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)]; |
新蟲 (小有名氣)
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 化工專碩求調(diào)劑 +5 | question挽風(fēng) 2026-03-24 | 5/250 |
|
|---|---|---|---|---|
|
[考研] 334分 一志愿武理 材料求調(diào)劑 +16 | 李李不服輸 2026-03-26 | 16/800 |
|
|
[考研] 303求調(diào)劑 +4 | DLkz1314. 2026-03-30 | 4/200 |
|
|
[考研] 300求調(diào)劑,材料科學(xué)英一數(shù)二 +18 | leaflight 2026-03-24 | 18/900 |
|
|
[考研] 085602 化學(xué)工程專碩 340分求調(diào)劑 +4 | qianbai11 2026-03-29 | 4/200 |
|
|
[考研] 085600材料與化工調(diào)劑 +6 | kikiki7 2026-03-30 | 6/300 |
|
|
[考研] 332求調(diào)劑 +6 | Lyy930824@ 2026-03-29 | 6/300 |
|
|
[考研] 285求調(diào)劑 +5 | AZMK 2026-03-29 | 8/400 |
|
|
[考研] 282求調(diào)劑 +4 | wcq131415 2026-03-24 | 4/200 |
|
|
[考研] 本科新能源科學(xué)與工程,一志愿華理能動(dòng)285求調(diào)劑 +7 | AZMK 2026-03-28 | 11/550 |
|
|
[考研] 藥學(xué)105500求調(diào)劑 +3 | Ssun。。 2026-03-28 | 3/150 |
|
|
[考研] 材料求調(diào)劑一志愿哈工大324 +7 | 閆旭東 2026-03-28 | 9/450 |
|
|
[考研] 295求調(diào)劑 +5 | 1428151015 2026-03-27 | 6/300 |
|
|
[考研] 0703化學(xué)求調(diào)劑,各位老師看看我。。 +5 | 祁祺祺 2026-03-25 | 5/250 |
|
|
[考研] 調(diào)劑推薦 +5 | 清酒714 2026-03-26 | 6/300 |
|
|
[考研] 一志愿 南京郵電大學(xué) 288分 材料考研 求調(diào)劑 +3 | jl0720 2026-03-26 | 3/150 |
|
|
[考研] 309求調(diào)劑 +4 | gajsj 2026-03-25 | 5/250 |
|
|
[考研] 303求調(diào)劑 +6 | 藍(lán)山月 2026-03-25 | 6/300 |
|
|
[考研]
|
黃粱一夢(mèng)千年 2026-03-24 | 3/150 |
|
|
[考研]
|
13659058978 2026-03-24 | 4/200 |
|