MATLAB Answers

how to plot a subject class

5 views (last 30 days)
vimal kumar chawda
vimal kumar chawda on 23 May 2019
Hello
I want to run same code 5 times with different satellite. How can I do it?
each satellite has different parameters are as below :-
function gps_(a,e,eta,omega_1,omega_2)=(26500,0.01,398600.44,0,0)
function gnss_(a,e,eta,omega_1,omega_2)=(42164.140,0,63,0,0)
function galileo_(a,e,eta,omega_1,omega_2)=(29994,0,56,0,0)
function champ_(a,e,eta,omega_1,omega_2)=(6838,0.004,87,0,0)
function molniya_(a,e,eta,omega_1,omega_2)=(26554,0.7,65,245,270)
so above 5 satellite how can I repeat 5 parameters again and again? Left hand side in brackets notation of the 5 parameters and on right hand side the value of the 5 parameters. Thank you :)
k=1;
for i=0:10:2*T
M= n *(i-0); %mean anomly
E0=M;
err=1;
while(err>10^-12)
E= M+e*sin(E0);
err=abs(E-E0); % I want to understand this step
E0=E; % eccentric anomly
end
v = 2*atan((sqrt(1+e/1-e)) *(tan(E/2))); %atan2 is not working % true anomly
r = a*(1-e*cos(E)); %distance of the satellite
r_b= [r*cos(v);r*sin(v);0] %position vector in the orbit system
r_b1(k,:)=[a*(cos(E)-e);a*(sqrt(1-(e*e)))*sin(E);0]; %position vector in the orbit system
v_b(k,:)=[-a*n*sin(E)*a/r;a*n*sqrt(1-(e*e))*cos(E)*a/r] %velocity vector in the orbit system
fi=deg2rad(0)
eta=deg2rad(55)
omega1=deg2rad(0)
omega2=deg2rad(0)
r_3= [cos(-fi) sin(-fi) 0;-sin(-fi) cos(-fi) 0;0 0 1]
r_1=[1 0 0;0 cos(-eta) sin(-eta);0 -sin(-eta) cos(-eta)]
r_i= r_3*r_1*r_3*r_b
r_i1(k,:)=transpose(r_i)
w_a=((2*pi)/86164)
phi=w_a*(i-0)
r_phi= [cos(phi) sin(phi) 0;-sin(phi) cos(phi) 0;0 0 1]
r_e=r_phi*r_i
r_e1(k,:)=r_phi*r_i
z_lat(k,:)= r_e1(k,3)
y_lat(k,:)=r_e1(k,2)
x_lat(k,:)=r_e1(k,1)
lat(k,:)= atan2((z_lat(k,:)),(sqrt((x_lat(k,:)*x_lat(k,:))+(y_lat(k,:)*y_lat(k,:)))))
long(k,:)= atan2(y_lat(k,:),x_lat(k,:))
r_w=[4075.53022;931.78130;4801.61819]
lat_w(k,:)=atan2(r_w(3,1),(sqrt(r_w(1,1)*r_w(1,1)+r_w(2,1)*r_w(2,1))))
long_w(k,:)=atan2(r_w(2,1),r_w(1,1))
A = [-sin(lat_w(k,:))*cos(long_w(k,:)) -sin(long_w(k,:)) cos(lat_w(k,:))*cos(long_w(k,:));-sin(lat_w(k,:))*sin(long_w(k,:)) cos(long_w(k,:)) cos(lat_w(k,:))*sin(long_w(k,:));cos(lat_w(k,:)) 0 sin(lat_w(k,:))]
r_top = transpose(A)*(r_e-r_w)
r_top1(k,:)=transpose(A)*(r_e-r_w)
S=sqrt(r_top(1,1).^2+r_top(2,1).^2+r_top(3,1).^2)
S_1(k,:)=sqrt(r_top1(k,1).^2+r_top1(k,2).^2+r_top1(k,3).^2)
zenit(k,:)=acos(r_top(3,1)/S);
Elevation(k,:)=(pi/2) -zenit(k,:)
Azi(k,:)= atan2(-r_top1(k,2),r_top1(k,1))
k=k+1;
end
fig1= plot3(r_e1(:,1),r_e1(:,2),r_e1(:,3))
fig2=plot3(r_i1(:,1),r_i1(:,2),r_i1(:,3))
pax=polaraxes;
pax.ThetaDir = 'clockwise';
fig3=polarplot(Azi,rad2deg(Elevation))
pax.RDir = 'reverse';
%fig4=polarplot(zenit,rad2deg(Elevation))
fig5=plot(long_deg,lat_deg)
hold on
plot(coastlon,coastlat)
hold off
mean_r_e=mean(r_e)
closest= mean(r_e-r_w)
please guide me ?
Thank you
Kind regards,
Vims Rocz
  4 Comments
vimal kumar chawda
vimal kumar chawda on 24 May 2019
like calling five times means
sorry sir but I didnot get you. can you please provide me an example so that i can do? how to call?
2- where do you want the satellite name to be mentioned? In a figure? Just pass the name of the satellite as an additional parameter to your function. Then reference this parameter in your code.
mySatelliteCode_gps(26500,0.01,398600.44,0,0)
mySatelliteCode_gnss(42164.140,0,63,0,0)
mySatelliteCode_galileo(29994,0,56,0,0)
mySatelliteCode_champ(6838,0.004,87,0,0)
mySatelliteCode_molniya(26554,0.7,65,245,270)
how to call this satellite parameters 5 times ?
Here I have to mention the parameters which i have mentioned in the code are as function mySatelliteCode(a,e,eta,omega_1,omega_2) so how one can do both at the same time?
thank you sir and sorry for late response I was having an exam.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!