필터 지우기
필터 지우기

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

조회 수: 1 (최근 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개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by