[討論] matlab 不知道哪個地方寫錯消失
請教各位大神
Q: 問題描述:傘兵問題,(1)求第十秒的速度,(2)依time stop=0.5 和 time stop=
1 ,繪出0到16秒到時間vs速度圖
以下是小弟的程式,不知道那裡錯,拜託幫忙指導
function value = veiocity3(dt,ti,tf,tv,vi,m,cd)
to(1)=0;vo(1)=0;
g=9.81; t=ti; v=vi;
n=(tf-ti)/dt;
for i=2:n+1
dvdt=deriv(v,m,cd);
t=t+dt;
to(i,1)=t;
vo(i,1)=v;
if t ==tv, value=v; end
end
vexact=sqrt(g*m/cd)*tanh(sqrt(g*cd/m)*to);
plot(to,vo,’b*-‘,to(:,1),vexact,’r-‘)
title(‘comparision of exact and numerical solution.’)
xlabel(‘values of time’)
ylabel(‘values of velocity’)
legend(strcat(‘dt=‘,num2str(dt)),’exact solution’)
function dv=deriv(v,m,cd)
g=9.81;
dv=g-(cd/m)*v^2;
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 39.12.230.132
※ 文章網址: https://www.ptt.cc/bbs/MATLAB/M.1506759403.A.7F6.html
推
10/03 01:03, , 1F
10/03 01:03, 1F
→
10/03 01:04, , 2F
10/03 01:04, 2F
→
10/03 01:04, , 3F
10/03 01:04, 3F
→
10/03 01:06, , 4F
10/03 01:06, 4F
推
10/03 01:57, , 5F
10/03 01:57, 5F
→
10/03 08:43, , 6F
10/03 08:43, 6F