Using if/else statement inside a for loop

5 visualizzazioni (ultimi 30 giorni)
Rahul Sugatra
Rahul Sugatra il 30 Apr 2019
Commentato: Rik il 1 Mag 2019
Greetings,
I'm running a "if" statement inside a for loop but the results doesn't consider the if statement conditions it just provides results with the last equation used in the loop. What I want is that for LocalTime between 9 to 16 if it is less than 12 then 1st equation should run upto 12'o clock then after 12 the 2nd equation values should be used and a final Results of 16(Hours)x31(days) should be generated.
*Solar Altitude Angle (SAA)*
for LocalTime=9:16
%U=(Time-((LST2-YY)+(S/2)))*15; %Hour Angle at LocalTime
U=(SNT-LocalTime)*15; %Hour Angle at LocalTime
HRADay(LocalTime,:)=U; %Hour Angle at LocalTime(Given Range)
SAA=asind((sind(d).*sind(Latitude))+(cosd(HRADay).*cosd(d).*cosd(Latitude)));
%%
% *Solar Azimuth Angle (SAZ)*
if LocalTime<=12
SAZ=abs(acosd((sind(d)-sind(SAA).*sind(Latitude))./(cosd(SAA).*cosd(Latitude))));
else
SAZ=360-abs(acosd((sind(d)-sind(SAA).*sind(Latitude))./(cosd(SAA).*cosd(Latitude))));
end
Results=SAZ;
end

Risposte (0)

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by