I need help with my MATLAB code. I am trying to propagte 10 different initial state vectors. In the end, I get 1 state matrix. I need to get 10 different state matrices for the 10 different initial state vectors. How do I store each state matrices seperately in MATLAB? R = 6378.0; %km mu = 398600.4415; %km^3/s^2 r = [7000, 0, 0, 0, 7.5, 0; 7100, 0, 0, 0, 7.6, 0; 7200, 0, 0, 0, 7.4, 0; 7300, 0, 0, 0, 7.3, 0; 7400, 0, 0, 0, 7.2, 0; 7500, 0, 0, 0, 7.1, 0; 7600, 0, 0, 0, 7.0, 0; 7700, 0, 0, 0, 6.9, 0; 7800, 0, 0, 0, 6.8, 0; 7900, 0, 0, 0, 6.7, 0]; % Initialize cell array to store results for each initial state results = cell(size(r, 1), 1); for i = 1:length(r) % Finding Period T_orbit = 2 * pi * sqrt((norm(r(i, :))^3) / mu); time_span = [0, T_orbit]; state_init = r(i, :); % Numerical integration using ODE solver options = odeset('RelTol', 1e-12, 'AbsTol', 1e-12); [t, state] = ode45(@(t, state) orbital_dynamics(t, state, mu), time_span, state_init, options); end %% Functions % Orbital dynamics function defining the differential equations function dstate_dt = orbital_dynamics(~, state, mu) % Extract position and velocity from state vector r = state(1:3); % Position vector [x; y; z] v = state(4:6); % Velocity vector [vx; vy; vz] % Compute the norm of the position vector r_norm = norm(r); % Gravitational acceleration (two-body central force) mu = 398600.4415; %km^3/s^2 a = -mu * r / r_norm^3; % Acceleration due to gravity % Assemble derivatives of state vector dstate_dt = [v; a]; % [dx/dt; dy/dt; dz/dt; dvx/dt; dvy/dt; dvz/dt] end
I need help with my MATLAB code. I am trying to propagte 10 different initial state vectors. In the end, I get 1 state matrix. I need to get 10 different state matrices for the 10 different initial state vectors. How do I store each state matrices seperately in MATLAB? R = 6378.0; %km mu = 398600.4415; %km^3/s^2 r = [7000, 0, 0, 0, 7.5, 0; 7100, 0, 0, 0, 7.6, 0; 7200, 0, 0, 0, 7.4, 0; 7300, 0, 0, 0, 7.3, 0; 7400, 0, 0, 0, 7.2, 0; 7500, 0, 0, 0, 7.1, 0; 7600, 0, 0, 0, 7.0, 0; 7700, 0, 0, 0, 6.9, 0; 7800, 0, 0, 0, 6.8, 0; 7900, 0, 0, 0, 6.7, 0]; % Initialize cell array to store results for each initial state results = cell(size(r, 1), 1); for i = 1:length(r) % Finding Period T_orbit = 2 * pi * sqrt((norm(r(i, :))^3) / mu); time_span = [0, T_orbit]; state_init = r(i, :); % Numerical integration using ODE solver options = odeset('RelTol', 1e-12, 'AbsTol', 1e-12); [t, state] = ode45(@(t, state) orbital_dynamics(t, state, mu), time_span, state_init, options); end %% Functions % Orbital dynamics function defining the differential equations function dstate_dt = orbital_dynamics(~, state, mu) % Extract position and velocity from state vector r = state(1:3); % Position vector [x; y; z] v = state(4:6); % Velocity vector [vx; vy; vz] % Compute the norm of the position vector r_norm = norm(r); % Gravitational acceleration (two-body central force) mu = 398600.4415; %km^3/s^2 a = -mu * r / r_norm^3; % Acceleration due to gravity % Assemble derivatives of state vector dstate_dt = [v; a]; % [dx/dt; dy/dt; dz/dt; dvx/dt; dvy/dt; dvz/dt] end
Principles of Heat Transfer (Activate Learning with these NEW titles from Engineering!)
8th Edition
ISBN:9781305387102
Author:Kreith, Frank; Manglik, Raj M.
Publisher:Kreith, Frank; Manglik, Raj M.
Chapter4: Numerical Analysis Of Heat Conduction
Section: Chapter Questions
Problem 4.6P
Related questions
Question
I need help with my MATLAB code. I am trying to propagte 10 different initial state
R = 6378.0; %km
mu = 398600.4415; %km^3/s^2
r = [7000, 0, 0, 0, 7.5, 0;
7100, 0, 0, 0, 7.6, 0;
7200, 0, 0, 0, 7.4, 0;
7300, 0, 0, 0, 7.3, 0;
7400, 0, 0, 0, 7.2, 0;
7500, 0, 0, 0, 7.1, 0;
7600, 0, 0, 0, 7.0, 0;
7700, 0, 0, 0, 6.9, 0;
7800, 0, 0, 0, 6.8, 0;
7900, 0, 0, 0, 6.7, 0];
% Initialize cell array to store results for each initial state
results = cell(size(r, 1), 1);
for i = 1:length(r)
% Finding Period
T_orbit = 2 * pi * sqrt((norm(r(i, :))^3) / mu);
time_span = [0, T_orbit];
state_init = r(i, :);
% Numerical integration using ODE solver
options = odeset('RelTol', 1e-12, 'AbsTol', 1e-12);
[t, state] = ode45(@(t, state) orbital_dynamics(t, state, mu), time_span, state_init, options);
end
%% Functions
% Orbital dynamics function defining the differential equations
function dstate_dt = orbital_dynamics(~, state, mu)
% Extract position and velocity from state vector
r = state(1:3); % Position vector [x; y; z]
v = state(4:6); % Velocity vector [vx; vy; vz]
% Compute the norm of the position vector
r_norm = norm(r);
% Gravitational acceleration (two-body central force)
mu = 398600.4415; %km^3/s^2
a = -mu * r / r_norm^3; % Acceleration due to gravity
% Assemble derivatives of state vector
dstate_dt = [v; a]; % [dx/dt; dy/dt; dz/dt; dvx/dt; dvy/dt; dvz/dt]
end
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Recommended textbooks for you

Principles of Heat Transfer (Activate Learning wi…
Mechanical Engineering
ISBN:
9781305387102
Author:
Kreith, Frank; Manglik, Raj M.
Publisher:
Cengage Learning

International Edition---engineering Mechanics: St…
Mechanical Engineering
ISBN:
9781305501607
Author:
Andrew Pytel And Jaan Kiusalaas
Publisher:
CENGAGE L

Refrigeration and Air Conditioning Technology (Mi…
Mechanical Engineering
ISBN:
9781305578296
Author:
John Tomczyk, Eugene Silberstein, Bill Whitman, Bill Johnson
Publisher:
Cengage Learning

Principles of Heat Transfer (Activate Learning wi…
Mechanical Engineering
ISBN:
9781305387102
Author:
Kreith, Frank; Manglik, Raj M.
Publisher:
Cengage Learning

International Edition---engineering Mechanics: St…
Mechanical Engineering
ISBN:
9781305501607
Author:
Andrew Pytel And Jaan Kiusalaas
Publisher:
CENGAGE L

Refrigeration and Air Conditioning Technology (Mi…
Mechanical Engineering
ISBN:
9781305578296
Author:
John Tomczyk, Eugene Silberstein, Bill Whitman, Bill Johnson
Publisher:
Cengage Learning

Automotive Technology: A Systems Approach (MindTa…
Mechanical Engineering
ISBN:
9781133612315
Author:
Jack Erjavec, Rob Thompson
Publisher:
Cengage Learning

Understanding Motor Controls
Mechanical Engineering
ISBN:
9781337798686
Author:
Stephen L. Herman
Publisher:
Delmar Cengage Learning

Mechanics of Materials (MindTap Course List)
Mechanical Engineering
ISBN:
9781337093347
Author:
Barry J. Goodno, James M. Gere
Publisher:
Cengage Learning