Euler's Method

16 visualizaciones (últimos 30 días)
Alexa Fernanda Cantú García
Alexa Fernanda Cantú García el 1 de Feb. de 2021
Editada: Alan Stevens el 2 de Feb. de 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

Respuestas (1)

Alan Stevens
Alan Stevens el 1 de Feb. de 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 comentarios
Alexa Fernanda Cantú García
Alexa Fernanda Cantú García el 1 de Feb. de 2021
But then I wouldn’t be using Euler’s Method?...
Alan Stevens
Alan Stevens el 1 de Feb. de 2021
Editada: Alan Stevens el 2 de Feb. de 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).

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by