Writing a differential equation for iteration using for loop.

8 次查看(过去 30 天)
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

采纳的回答

Alan Stevens
Alan Stevens 2020-11-12
编辑:Alan Stevens 2020-11-12
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by