Effacer les filtres
Effacer les filtres

Writing a differential equation for iteration using for loop.

9 vues (au cours des 30 derniers jours)
Heya :)
Heya :) le 12 Nov 2020
Commenté : Heya :) le 13 Nov 2020
I have a differential equation:
p=@(t,x,y) (a-x^2-y^2)*x-omega*y;
Why for iteration we write this equation as ?
for i=2:50000
x(i)=x(i-1)+((a-x(i-1)^2-y(i-1)^2)*x(i-1)-omega*y(i-1))*dt;
end

Réponse acceptée

Alan Stevens
Alan Stevens le 12 Nov 2020
Modifié(e) : Alan Stevens le 12 Nov 2020
This is known as simple Euler integration. It arises from
% dx/dt = (a - x^2 - y^2)*x - omega*y
% Let dx/dt be approximated by (x(t+dt) - x(t))/dt
% and the right hand side by (a - x(t)^2 - y(t)^2)*x(t) - omega*y(t)
% so (x(t+dt) - x(t))/dt = (a - x(t)^2 - y(t)^2)*x(t) - omega*y(t) approximately
% Multiply both sides by dt to get
% x(t+dt) - x(t) = ((a - x(t)^2 - y(t)^2)*x(t) - omega*y(t))*dt
% Add x(t) to both sides to get
% x(t+dt) = x(t) + ((a - x(t)^2 - y(t)^2)*x(t) - omega*y(t))*dt

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by