Filter löschen
Filter löschen

Sir Model using Forward Euler

4 Ansichten (letzte 30 Tage)
Cooper McCleery
Cooper McCleery am 9 Feb. 2021
% Solve the system x'=y, y'=-x using Forward Euler
clear all;
clc;
h=0.001;
T=10.0;
xs=0.2;
x(1)=xs;
ys=0.3;
y(1)=ys;
ts=0.;
t(1)=ts;
index=1;
while ts<=T
ts
%Forward Euler Step
ts=ts+h;
xshold=xs+h*ys;
ys=ys-h*xs;
xs=xshold;
index=index+1;
x(index)=xs;
y(index)=ys;
t(index)=ts;
end
figure(1)
plot(t,x); hold on;
plot(t,y,'g')
figure(2)
plot(x,y)
Here is the code for Forward Euler that my professor has provided us. The photo below are the given equations for the problem. I need to solve the ODE using forward euler. I am struggling to comprehend even where to start for putting the equations in.
  1 Kommentar
darova
darova am 11 Feb. 2021
Bearbeitet: darova am 11 Feb. 2021
Please ask something specific. Look here: LINK

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Pratheek Punchathody
Pratheek Punchathody am 12 Feb. 2021
Refer to the similar answer in the Community which will help you in resolving.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by