![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/727389/image.png)
Euler's method in matlab
2 ビュー (過去 30 日間)
古いコメントを表示
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?
0 件のコメント
採用された回答
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 ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/727389/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/727389/image.png)
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!