Writing a differential equation for iteration using for loop.

14 visualizaciones (últimos 30 días)
Heya :)
Heya :) el 12 de Nov. de 2020
Comentada: Heya :) el 13 de Nov. de 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

Respuesta aceptada

Alan Stevens
Alan Stevens el 12 de Nov. de 2020
Editada: Alan Stevens el 12 de Nov. de 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

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by