Asked by Bilal Arshed
on 18 Nov 2019 at 16:48

i know some boundary conditions such as, t0= 0 and v0=7000m/s (<===newly updated v0) and vf=0.... but do not know what, tf, i equal to.

Answer by darova
on 18 Nov 2019 at 21:40

- Any guidance on it is much appreciated!

Helpfull page: ODE45

- I do not know what I can do if I no tf.

Try tf = 5. This should work

James Tursa
on 18 Nov 2019 at 22:30

Bilal Arshed
on 18 Nov 2019 at 22:30

i don't think so, that usually works just fine.

Bilal Arshed
on 18 Nov 2019 at 22:32

% { you can just use placeholder values for global variables like L and D.

function dv = myeqn(t, v)

mu_e = 3.986e14;

r=6378e3;

m=5000;

global L;

global D;

gamma=40; % not sure what to start at

v0=7000;

t0=0;

tend=5;

[t,v] = ode45(@myeqn, [t0,tend], v0)

dv = ((mu_e)./(r^2)) + ((v^2)./r) + (1./m)*(D*sin(gamma)+L*cos(gamma)); % radial accel equation

Sign in to comment.

Answer by James Tursa
on 18 Nov 2019 at 22:46

Edited by James Tursa
on 18 Nov 2019 at 23:04

You've got two 2nd order DE's, so that means you have a 4th order system (2x2=4) and thus your state vector will contain four elements. You could define them as follows:

y = your 4x1 state vector with the following definitions

y(1) = r_r

y(2) = v_r

y(3) = r_t

y(4) = v_t

Then your derivative function outline would be:

function dy = myeqn(t, y)

% put some constants here or pass them in, e.g. mu etc.

dy = zeros(size(y));

dy(1) = y(2); % derivative of r_r is v_r

dy(2) = ___; % you fill this in from your r_r doubledot equation

dy(3) = y(4); % derivative of r_t is v_t

dy(4) = ___; % you fill this in from your r_t doubledot equation

end

For the dy(2) and dy(4) code, you will need to calculate your gamma value from the y vector. You could either hardcode the other stuff (D, L, m, etc.) or pass them in as input arguments. To start with, you will need to define initial values for all four states, not just v0. Also, I would have expected to see a factor somewhere on the r_t double dot equation based on the atmospheric density (a function of altitude), but I don't see it ... and this seems suspicious to me.

Bilal Arshed
on 18 Nov 2019 at 22:54

thanks, it is pretty late here so i will have a look into this tommorow morning. if all goes well i will accept the answer but i might have question when i come to atmepting it.

Thank you for helping, much appreciated!

P.S what is the y vector?

Is this the vector created by combining the tangent and radial velocities?

James Tursa
on 18 Nov 2019 at 23:06

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 4 Comments

## darova (view profile)

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/491737-numerically-integrating-the-differential-equation-below#comment_768652

## Bilal Arshed (view profile)

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/491737-numerically-integrating-the-differential-equation-below#comment_768655

## James Tursa (view profile)

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/491737-numerically-integrating-the-differential-equation-below#comment_768678

## Bilal Arshed (view profile)

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/491737-numerically-integrating-the-differential-equation-below#comment_768682

Sign in to comment.