Forward Euler method for Higher order differential equation
Ältere Kommentare anzeigen
Helloo!
I am trying to solve a third order differential equation using forward euler method. The differential equation is : y''' = 2 y'' + 6y ; y(0) =1, y'(0) = 0, y''(0)=1, interval is [0, 5], step size= 0.001. here the derivative is with respect to time (t). I dont know how to proceed further and do the iteration. I tried to change the above differential equation into a first order differential equation but then I dont know how to proceed with the code.
y(1) = y ;
y(2) = y' = y(1)'
y(3) = y'' = y(2)'
y(3)' = 2 y(3) + 6 y(1)
Below is a code which I used to solve first order differential equation using euler method. Please help.
clear
close all
clc
%%
t0 = 0; %initial value
y0 = 1; %initial condition(given)
tEnd = 5; %end of time step
h = 0.001; %step size
N = (tEnd-t0)/h; %number of interval
T = t0:h:tEnd;
Y = zeros(1, N+1);
Y(1) = y0;
for i = 1:N
fi = %function
Y(i+ 1) = Y(i) + h * fi;
end
%%
%ploting===================================================================
plot(T,Y,'.','LineWidth',2);
title('Approximate solution Euler Explicit Method')
1 Kommentar
Cr0ke
am 25 Jan. 2021
@Hrishikesh Das Did you found the problem and did you make it?
Akzeptierte Antwort
Weitere Antworten (1)
Ameer Hamza
am 28 Apr. 2020
0 Stimmen
You can download the zip file given in this answer: https://www.mathworks.com/matlabcentral/answers/98293-is-there-a-fixed-step-ordinary-differential-equation-ode-solver-in-matlab-8-0-r2012b#answer_107643 and study the code of ode1.m. It is the implementation of the Euler method provided by Mathworks in very early releases of MATLAB. It is no longer included in MATLAB by default, but it is still useful to understand the implementation of the Euler method for higher-order ODEs.
4 Kommentare
Hrishikesh Das
am 28 Apr. 2020
Ameer Hamza
am 28 Apr. 2020
Glad to be of help. That code will help you to correct your implementation.
Hrishikesh Das
am 28 Apr. 2020
Ameer Hamza
am 28 Apr. 2020
You can see James' answer. You can follow that hint to implement multiple ODEs using Euler.
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!