Ode45 initial conditions iteration
Afficher commentaires plus anciens
I am trying to solve the following 2nd order differential equation, which works fine but I need to iterate the initial conditions, so everytime the ode is solved, the last values for q(:,1) and q(:,2) should be the new value for X and Y respectivley.
%solve_2nd_order_diff
duf=@(t,q)[q(2);f*w^2*cos(w*t)-(Cmech/J)*q(2)-(K1/J)*q(1)-(K3/J)*q(1)^3];
for r=1:length(Rad_speed)%freq of harmonic fluctuations, rad/s
[t,q]=ode45(duf,Time,[X Y]);
Max_values=max(q);
plot(t,q(:,1),'k')
xlabel('TIme,s')
ylabel('Relative Displacement, Rad')
grid
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!