Frequency sweap euler's model

1 回表示 (過去 30 日間)
letoppina
letoppina 2018 年 12 月 14 日
編集済み: letoppina 2018 年 12 月 14 日
Hello,
I am trying to solve a differential equation using the euler's model:
for ii=1:length(t)-1
du = M*a(ii) + C;
u(ii+1) = u(ii) + du*dt;
end
Where u and a are vectors with the same length of the time vector (defined in my code) and dt is the timestep.
Particularly, a(ii) is defined as a sinusoidal function as following:
a = sin(w*t)
I would like to make the frequency vary so I have made a linspace vector for w:
w = linspace(0, 100, 100)
therefore, mu final code is made of 2 loops:
for j=1:lentgh(w)
for ii=1:length(t)-1
du(j) = M*a(j,ii) + C;
u(j,ii+1) = u(j,ii) + du(j)*dt;
end
end
I am obviously here because my code gives some errors. How can I fix the code? Do you have other suggestions in order to make a frequency sweap run (with differential equations involved)?

回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by