Writing a differential equation for iteration using for loop.

9 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Alan Stevens
Alan Stevens il 12 Nov 2020
Modificato: Alan Stevens il 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

Più risposte (0)

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by