Error using Euler Method

7 Ansichten (letzte 30 Tage)
Laura Del Ponte
Laura Del Ponte am 8 Nov. 2020
Beantwortet: Alemtaye am 1 Jul. 2022
I am trying to find the approximate value for N=50and this is the code I have written:
f =inline('0.7*y','t','y') ;
t = linspace (0 ,5 ,100);
y = -2* exp (0.7* t ); % define exact solution of the ODE
[ t50 , y50 ]= euler (f ,[0 ,5] , -2 ,50); % solve the ODE using Euler w/ 50 steps
y50(end);
This code is literally provided by my teacher but it keeps saying Error in the line with the euler code. It is saying "Check for missing argument or incorrect argument data taype in call to function 'euler'.

Antworten (2)

Ameer Hamza
Ameer Hamza am 8 Nov. 2020
I think your teacher expects you to write euler() function yourself. MATLAB does not have a built-in function named euler() for solving ODEs. You can find the code of the Euler method here: https://www.mathworks.com/matlabcentral/answers/98293-is-there-a-fixed-step-ordinary-differential-equation-ode-solver-in-matlab-8-0-r2012b. Download the zip file and check the code for ode1.m

Alemtaye
Alemtaye am 1 Jul. 2022
Write matlab code using euler method step size h=0.2,1,0.05.compute the error and relative error y'(t)=[cos(y(t))]^2,0<=t<=10,y(0)=0

Kategorien

Mehr zu Numerical Integration and Differential Equations 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