"Array indices must be positive integers or logical values." Error Message

1 visualización (últimos 30 días)
Samuel Ross
Samuel Ross el 26 de Feb. de 2020
Editada: KSSV el 26 de Feb. de 2020
%This is my code, and I'm trying to set the individual values of the Rpqw matrix as the formula listed, but I keep getting the error in the title.
close all
clear
clc
%establish COEs
a = 15000;
e = .4;
i = 40;
RA = 20;
w = 200;
v = 350;
mu = 3.986*10^5;
%establish directional vectors
P = [1;0;0];
Q = [0;1;0];
R = [0;0;1];
%Establish cosines and sines of orbital elements
cv = cosd(v);
sv = sind(v);
cRA = cosd(RA);
sRA = sind(RA);
cw = cosd(w);
sw = sind(w);
ci = cosd(i);
si = sind(i);
%Find Rpqw and Vpqw
Rpqw = zeros(3,1);
Rpqw(1) = ((a(1-e^2))/(1+e*cv))*cv;
Rpqw(2) = ((a(1-e^2))/(1+e*cv))*sv;

Respuestas (1)

KSSV
KSSV el 26 de Feb. de 2020
Editada: KSSV el 26 de Feb. de 2020
((a(1-e^2)) This is not correct......I think you want
((a*(1-e^2))
close all
clear
clc
%establish COEs
a = 15000;
e = .4;
i = 40;
RA = 20;
w = 200;
v = 350;
mu = 3.986*10^5;
%establish directional vectors
P = [1;0;0];
Q = [0;1;0];
R = [0;0;1];
%Establish cosines and sines of orbital elements
cv = cosd(v);
sv = sind(v);
cRA = cosd(RA);
sRA = sind(RA);
cw = cosd(w);
sw = sind(w);
ci = cosd(i);
si = sind(i);
%Find Rpqw and Vpqw
Rpqw = zeros(3,1);
Rpqw(1) = ((a*(1-e^2))/(1+e*cv))*cv;
Rpqw(2) = ((a*(1-e^2))/(1+e*cv))*sv;

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by