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

%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;

답변 (1개)

KSSV
KSSV 2020년 2월 26일
편집: KSSV 2020년 2월 26일
((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;

카테고리

도움말 센터File Exchange에서 Prepare Model Inputs and Outputs에 대해 자세히 알아보기

태그

질문:

2020년 2월 26일

편집:

2020년 2월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by