finding magnitude of a vector

133 views (last 30 days)
Ashlianne Sharma on 7 Nov 2020
Hi all, I am trying to make a function and the first step within my function is to find the magnitude of a vector that I have named on another script. How do I do this? I willo put my code below to explain more.
FROM FUNCTION PAGE
function[a, e, nu, i, O, m] = hw_COE_sharmaAshlianne(R, V)
% Inputs
% R = Radius vector [km]
% V = Velocity vector [km/s]
%
% Outputs
% a = semi major axis [km]
% e = eccentricity [no units]
% nu = true anomoly [degrees]
% i = inclination [degrees]
% O = right ascention of the ascending node(RAAN) [degrees]
% w = argument of perigee [degrees]
% Known values
m = 398600; % [km^3/s^2]
% Step one find the magnitude of the radius and velocity vectors
r = norm(R);
v = norm(V);
FROM SCRIPT
% Create a structure for our function to find COE parameters
Rvector = [15370 1400 21950]; % [km]
Vvector = [-0.1 3.84 -0.2]; % [km/s]
% Call function with the structured variables we created above
[a, e, nu, i, O, m] = hw_COE_sharmaAshlianne(Rvector, Vvector);
so to reiterate my question, how do I find the magnitude of Rvector that is defined in my script on my function page (STEP ONE IN FUNCTION)
Ashlianne Sharma on 8 Nov 2020
Okay, Thank you so much for your help!! i will definitely look more to the page you sent me, I think that may be very useful. Again, Thank you so much for taking So SO much time out to help me. I am just a struggling college student haha but yes, I really appreciate your time and help Vasishta!