Clear Filters
Clear Filters

Euler's Method

5 views (last 30 days)
Alexa Fernanda Cantú García
Edited: Alan Stevens on 2 Feb 2021
I'm trying to solve the following problem by the Euler Method:
A parachutist of mass 68.1 kg jumps out of a stationary hot air balloon. Use Eq. (1.10) to compute velocity prior to opening the chute. The drag coefficient is equal to 12.5 kg/s.
The book gives me already the equation which is:
v=53.44(1-e^-0.18355*t)
I understand that mi initial values are:
x(0)=0
y(0)=0
h=2
x(f)=12
where x is t and y is v.
The table below are the answers but my code doesn't give me that solution.
The answers i get by my code:
MY CODE
clear all
clc
f=@(x,y) 53.44*(1-exp(-0.1835*x)); %Write your f(x,y) function, where dy/dx=f(x,y), x(x0)=y0.
x0=input('\n Enter initial value of x i.e. x0: '); %example x0=0
y0=input('\n Enter initial value of y i.e. y0: '); %example y0=0.5
xn=input('\n Enter the final value of x: ');% where we need to find the value of y
%example x=2
h=input('\n Enter the step length h: '); %example h=0.2
%Formula: y1=y0+h*fun(x0,y0);
fprintf('\n x y ');
while x0<=xn
fprintf('\n%4.3f %4.3f ',x0,y0); %values of x and y
y1=y0+h*f(x0,y0);
x1=x0+h;
x0=x1;
y0=y1;
end

Answers (1)

Alan Stevens
Alan Stevens on 1 Feb 2021
Since you are given velocity as a function of time, why don't you simply plug the desired values of time directly into the function?
vel = @(t) 53.44*(1 - exp(-0.18355*t));
t = [0; 2; 4; 6; 8; 10; 12; inf];
v = vel(t);
disp([t v])
Your function is a velocity, not a rate of change of velocity with time, so your statement
y1=y0+h*f(x0,y0);
doesn't result in a velocity, but a distance (though your timestep is probably too big for an accurate result).
  4 Comments
Alexa Fernanda Cantú García
But then I wouldn’t be using Euler’s Method?...
Alan Stevens
Alan Stevens on 1 Feb 2021
Edited: Alan Stevens on 2 Feb 2021
To use Euler's method to calcuate veocities here, you need an acceleration (which you can get by differentiating the velocity function with respect to time). So, then your integration routine would look something like:
t = 0;
v = 0;
while t <= tfinal
v = v + h*acc(t);
t = t + h;
end
where acc is your acceleration function and h is your timestep size (I'd suggest using a much smaller value than 2 to get reasonably accurate resuts).

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!