単振動をオイラー法で数値シミュレーション
Show older comments
v=A*omega*cos(omega*t+alpha);
上記の単振動の公式を使ってこれをオイラー法で近似したいと思いますが、
for ループがうまくいかないです。
恐らくvをスカラー値にしたらできると思うのですが、これではyがスカラー値になってしまっていると思うのですが
どのように変更するのかわかりません。
もし分かれば教えていただきたいです
よろしくお願いいたします。
A=10;
alpha=pi./2;
omega=2*pi;
h=1/250;
y(1)=10;
N=1+4/h;
t=0:h:4;
for i=1:1:N;
v=A*omega*cos(omega*t+alpha);
v0=0;
y(i+1)=y(i)+v*h; %ここでエラーが出ます。
t(i+1)=t(i)+h;
end
yy=y(1,1:N);
plot(t(1,:),y(1,:),'-o');
hold on
plot(t,v,'-o');
Accepted Answer
More Answers (0)
Categories
Find more on パフォーマンスとメモリ in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!