Filter löschen
Filter löschen

Using for/while for a repeating task: average solar irradiation of every month

1 Ansicht (letzte 30 Tage)
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

Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by