Using for/while for a repeating task: average solar irradiation of every month
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello everybody.
[MonthNum, MonthStr]=month(t), t is datetime
I tried to create MonthNum with the month function and comparing each element in the vector i, if its for example january. My Question is: can I use a loop for that task? I know that I can get two outputs from the month function, but it´s not workin for me. I thougt that I can use the MonthString for the name of the month.
Jan=mean(i(MonthNum==1),'omitnan');
Feb=mean(i(MonthNum==2),'omitnan');
Mar=mean(i(MonthNum==3),'omitnan');
Apr=mean(i(MonthNum==4),'omitnan');
Mai=mean(i(MonthNum==5),'omitnan');
Jun=mean(i(MonthNum==6),'omitnan');
Jul=mean(i(MonthNum==7),'omitnan');
Aug=mean(i(MonthNum==8),'omitnan');
Sep=mean(i(MonthNum==9),'omitnan');
Okt=mean(i(MonthNum==10),'omitnan');
Nov=mean(i(MonthNum==11),'omitnan');
Dez=mean(i(MonthNum==12),'omitnan');
Year=[iJan;iFeb;iMar;iApr;iMai;iJun;iJul;iAug;iSep;iOkt;iNov;iDez];
%maybe like that:
for k=1:12
MonthString(k)=mean(i(MonthNum==k),'omitnan');
end
I never came to the part with the for loop because the month function creates an error: too many output arguments.
Thanks for helping
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Solar Power에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!