Deleted The Following Issue was solved.

1 view (last 30 days)
Enginsale
Enginsale on 29 Mar 2015
Edited: Enginsale on 12 Jan 2017
I have the following code , i'm trying to convert from Cartesian coordinates to polar but so far when i plot , the plot is empty.
Latitude=31.13;
for n=1:30:365/2;
for h=-12:0.1:12
w=15*h;
delta=23.45*sind((360/365)*(284+n)); %Declination Angle
alpha=asind(sind(delta)*sind(Latitude)+cosd(delta)*cosd(w)*cosd(Latitude));%Solar Altitude Angle
gamma1=asind(cosd(delta)*sind(w)/(cosd(alpha)));%Azimuth Angle Dashed
we=acosd(tand(delta)/tand(Latitude));
if abs(w)<we
C1=1;
else
C1=-1;
end
if Latitude*(Latitude-delta)>=0
C2=1;
else
C2=-1;
end
if w>=0
C3=1;
else
C3=-1;
end
Gamma=C1*C2*gamma1+C3*((1-C1*C2)/2)*180;
[phi,r]=cart2pol(Gamma,alpha);
polar(phi,r)
end
end
  3 Comments
Star Strider
Star Strider on 29 Mar 2015
I apologise for repeating myself, but as I wrote in my first Comment: ‘but if you want to reference them by ‘h’, you need to use a counter that increments with each value of ‘h’, because ‘h’ begins with a negative value and has fractional increments’
So I would create the counter as:
for n=1:30:365/2;
k1 = 0;
for h=-12:0.1:12
k1 = k1 + 1;
... CODE ...
Gamma_array(n,k1) = Gamma;
alpha_array(n,k1) = alpha;
end
end
See if that does what you want.
Rena Berman
Rena Berman on 12 Jan 2017
(Answers Dev) Restored question.

Sign in to comment.

Answers (0)

Categories

Find more on Cartesian Coordinate System Conversion in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!