Using if/else statement inside a for loop
조회 수: 6 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!