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
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
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!