Using for/while for a repeating task: average solar irradiation of every month
2 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Solar Power in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!