Frequency sweap euler's model
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!