作者nung1109 (nung)
看板MATLAB
标题[讨论]请问时间对y作图
时间Sat Jan 7 14:38:44 2017
版上的各位:
我目前是在octave操作,但似乎没有octave的版,所以在这里询问,谢谢。
我想要当时间到10~15时,H为1,其他时候H为0,但画不出来不知道是哪里有问题,还请大家帮帮忙,谢谢。
_____function file__
function dydt=ps3_1_3_hill_fun(t,y)
H=0;
for 10<t<15
H=1;
end
dydt=1900*H+100-2*y;
end
_____main file_
clear off;
[t,y]=ode45(@ps3_1_3_hill_fun,[0,25],0);
plot(t,y)
______________
另外想请问function档为何都要另存呢?跟写画图的档案一起不行吗?谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 221.169.117.47
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/MATLAB/M.1483771127.A.BBB.html
1F:→ tomichy: for 10<t<15 <=== 这..电脑看不懂吧 01/09 22:34
2F:推 sppmg: function档可以内含多个子函数,把原main改成函数吧 01/09 23:01
3F:→ sppmg: 然後上面是 for I=[10:15] 01/09 23:02