Euler's method in matlab

조회 수: 2 (최근 30일)
Haya Ali
Haya Ali 2021년 9월 2일
편집: Haya Ali 2021년 9월 8일
If I write the model using Euler's method. Like this
clear all; close all; clc;
%value of constants
a_n=0.1;
omega_0=2;
dt=0.01; %step size
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x(1)=1;
y(1)=1;
for i=2:1000
x(i)=x(i-1)+((a-x(i-1)^2-y(i-1)^2)*x(i-1)-omega_0*y(i-1))*dt;
y(i)=y(i-1)+((a-x(i-1)^2-y(i-1)^2)*y(i-1)+omega_0*x(i-1))*dt;
end
Does that mean it will give me values of x and y instead of dx/dt and dy/dt?

채택된 답변

Fabio Freschi
Fabio Freschi 2021년 9월 2일
편집: Fabio Freschi 2021년 9월 2일
Any ODE solver gives the unknown function(s) as result, not its derivative. So, yes, your results are x and y.
Note that in your solution you forgot the term

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by