Asked by hknatas
on 10 Nov 2018

Hello. How to code this situation?

In this situation i need to calculate all angular velocities from time 0s to time 5400s with increase by 0.1s and graph them.

I have all the initial values:

wxi = 0.0065

wyi = 0.0066

wzi = 0.0067

And constant values:

NT = 3.6 * 10^-10

Jx = 2.1 * 10^-3

Jy = 2.0 * 10^-3

Jz = 1.9 * 10^-3

Actually i thought it is going to be easy but when i write the code for wx, i realized that wx is increasing with time but wz and wy in the equation are constant values. Which kind of loop should i use? Thanks for the answers!

Answer by Bruno Luong
on 10 Nov 2018

Accepted Answer

Actually i thought it is going to be easy but when i write the code for wx, i realized that wx is increasing with time but wz and wy in the equation are constant values.

Just copy the value in 3 different variables, then do the calculation.

hknatas
on 11 Nov 2018

Walter Roberson
on 11 Nov 2018

delta_t = 0.1;

time_vals = 0 : delta_t : 5400;

N_times = length(time_vals);

n = 63;

Wx = zeros(1, N_times);

Wy = zeros(1, N_times);

Wz = zeros(1, N_times);

Wx(1) = 0.0002 + 0.0001 * n; % 0.0065

Wy(1) = 0.0003 + 0.0001 * n; %0.0066

Wz(1) = 0.0004 + 0.0001 * n; %0.0067

% The initial moments of inertia of the satellite ( m^4 ):

Jx = 2.1e-03;

Jy = 2e-03;

Jz = 1.9e-03;

% The disturbance torque acting on the satellite ( N.m ):

NT = 3.6e-10;

for i = 1 : N_times - 1

Wx(i+1) = Wx(i) + delta_t / Jx * (Wz(i) * Wy(i) + NT)*(Jy - Jz);

Wy(i+1) = Wy(i) + delta_t / Jy * (Wx(i) * Wz(i) + NT)*(Jz - Jx);

Wz(i+1) = Wz(i) + delta_t / Jz * (Wx(i) * Wy(i) + NT)*(Jx - Jy);

end

plot(time_vals, Wx);

hknatas
on 11 Nov 2018

Thanks for everything, especially for your patience. This really helps a lot.

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 5 Comments

## Walter Roberson (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/429151-how-to-solve-3-equations-dependent-each-other#comment_635451

## hknatas (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/429151-how-to-solve-3-equations-dependent-each-other#comment_635458

## Walter Roberson (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/429151-how-to-solve-3-equations-dependent-each-other#comment_635461

## hknatas (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/429151-how-to-solve-3-equations-dependent-each-other#comment_635472

## hknatas (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/429151-how-to-solve-3-equations-dependent-each-other#comment_635478

Sign in to comment.