Help with using arrays to create variables
古いコメントを表示
I'm trying to use arrays to create variables related to 32 different satellites (which I currently have fully written out it's awful making changes) orbiting a planet and am getting stuck quite early on. As a small example I'm trying to get working, I've got two angles for each satellite (being done in blocks of 8), th0(i) and th(i). The angle th0 works fine, however th relies upon th0 and a parameter, also an angle, called M, which relies on time. As I have 148 timesteps, M is a 148x1 array. When I input my code below, I get an error about the element numbers not matching up. I tried using the transverse of th and th0 but no joy. Can anyone suggest my next move?
%%Relevant parameters
timestep = 600;
G = 6.67408*10^-11; %[m^3kg^-1s^-2]
% Mars data
Mars.m = 6.39*10^23; %[kg]
Mars.mu = Mars.m*G; %[m^3s^-2]
Mars.r = 3389.5*10^3; %[m]
Mars.v = 241.17; %[ms^-1]
Mars.T = (2*pi*Mars.r)/Mars.v; %[s]
Mars.o = Mars.v/Mars.r; %[rads^-1]
Mars.th = Mars.o*timestep; %[rad] for every second
t = (0:timestep:Mars.T)'; %Mars.T, Length of martian day in seconds
H1 = 9610.5*10^3; %[m]
a1 = Mars.r + H1; %[m]
T1 = 2*pi*sqrt(a1^3/Mars.mu); %[s]
n1 = (2*pi)/T1; %[kms^-1]
M1 = n1*t; %[rad]
%%Test Section
th0 = zeros(1,length(t));
th = zeros(1,length(t));
for i = 1:8
th0(i) = deg2rad(45*(i-1));
th(i) = th0(i) + 2*atan(tan(M1/2));
end
4 件のコメント
Stephan
2018 年 10 月 25 日
G is missing
Scott Hunter
2018 年 10 月 25 日
Scott Hunter
2018 年 10 月 25 日
Stephan
2018 年 10 月 25 日
Die you try the code from my answer?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!