Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

I need help with programming in MATLAB. The following code transforms cartesian coordinates to the kepler elements. Can you give me the code for transforming kepler orbital elements to cartesian coordinates. The following code gives the 6 kepler elements. Transform those elements into cartesian coordinate that match the values under the Example Usage part of the code. Can you send a screenshot so I know the output of your code matches the input of the following code? I have asked this question twice and I have gotten the exact same code as the answer and it did not match. Please make sure the results match.

% Example usage:
x = 1000;
y = 2000;
z = 3000;
vx = 4;
vy = -3;
vz = 2;

[a, ecc, inc, raan, argp, f] = cart2orb(x, y, z, vx, vy, vz);

% Display the results
disp(['Semi-Major Axis (a): ', num2str(a), ' km']);
disp(['Eccentricity (ecc): ', num2str(ecc)]);
disp(['Inclination (inc): ', num2str(inc), ' degrees']);
disp(['Right Ascension of Ascending Node (raan): ', num2str(raan), ' degrees']);
disp(['Argument of Perigee (argp): ', num2str(argp), ' degrees']);
disp(['True Anomaly (f): ', num2str(f), ' degrees']);

function [a, e, inc, raan, argp, f] = cart2orb(x, y, z, vx, vy, vz)
% Gravitational constant for Earth (μ⊕)
mu = 398600.4418; % km^3/s^2

% Calculate position and velocity vectors
r = [x; y; z]; % Position vector
v = [vx; vy; vz]; % Velocity vector

% Calculate orbital parameters
h = cross(r, v); % Specific angular momentum vector
n = cross([0; 0; 1], h); % Nodal vector

% Eccentricity (ecc)
e_vec = (cross(v,h)/mu) - (r/norm(r));
%e_vec = ((norm(v)^2 - mu/norm(r)) * r - dot(r, v) * v) / mu;
e = norm(e_vec);

% Semi-major axis (a)
a = (dot(h,h)/mu) / (1-e^2);
%a = 1 / (2/norm(r) - norm(v)^2/mu_earth);

% Inclination (inc)
inc = acosd(h(3) / norm(h));

% Right Ascension of Ascending Node (raan)
raan = atan2d(n(2), n(1));
raan = mod(raan + 360, 360); % Ensure raan is in the range [0, 360)

% Argument of Perigee (argp)
argp = atan2d(dot(n, cross(e_vec, h)), dot(n, e_vec));
argp = mod(argp + 360, 360); % Ensure argp is in the range [0, 360)

% True Anomaly (f)
f = atan2d(dot(e_vec, cross(h, r)), dot(e_vec, r));
f = mod(f + 360, 360); % Ensure f is in the range [0, 360)
end

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education