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 CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by