finding magnitude of a vector

27 次查看(过去 30 天)
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)
  16 个评论
VBBV
VBBV 2020-11-8
编辑:VBBV 2020-11-8
Check the syntax of function declaration. You require space between the word function and output variable vector
%if true
% code
%end
function [a,e,nu,i,O,m]=
w_COE_sharmaAshlianne(Rvector,Vvector)
...
r = norm(Rvector);
v = norm(Vvector)
...
end % close function file with end statement
Ashlianne Sharma
Ashlianne Sharma 2020-11-8
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!

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by