Gathering data from a for loop

Hi, im trying to create 3 plots from matlab (mean anomaly (M), eccentricity (E), and true anomaly (nue)) but by using the fzero I can't make t an array so Im using a for loop. How can I properly save the data for M, E and nue fir each loop as a function of t so I can plot it? Thanks
t=0;
T=12*3600;
mu=398600; %km3/s
aa=(((T/(2*pi))^2)*mu)^(1/3) %km semi-major axis
ee=1-((6378+500)/aa) %eccentricity
nn=sqrt(mu/(aa^3)) %mean motion
M0=0; %initial mean anomaly
E0=0; %initial eccentric anomally
for t=0:1200:43200
M=M0 + nn*t;
M=mod(M,2*pi)
%MeanAnomaly(t)=M;
E=fzero(@(E)(M-E+ee*sin(E)),M)
%Eccentric(t,;)=E;
nue=2*atan(sqrt((1+ee)/(1-ee))*tan(E/2))
%Trueanomaly(t)=nue;
end

Risposte (1)

something like this:
t=0:1200:43200;
M=zeros(size(t));
for k=1:numel(t)
M(k)=M0 + nn*t(k);
end
plot(t,M)

Richiesto:

il 25 Ott 2018

Risposto:

il 25 Ott 2018

Community Treasure Hunt

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

Start Hunting!

Translated by