365 day loop for 59 years
이전 댓글 표시
Hi there,
This is a beginner question, I'm very new to MATLAB.
I have 59 years worth of data in one column starting in October. There is 1 data point for every day in the year. I would like to create a loop which produces a graph for the data in every year for each of the 59 years.
Thanks,
SS.
댓글 수: 4
Mathieu NOE
2021년 2월 23일
hello
maybe you should share the data file to let us help you
Cris LaPierre
2021년 2월 23일
Don't forget - every 4 years there are 366 days.
David Hill
2021년 2월 23일
Show us the code you currently have.
S.S
2021년 2월 23일
답변 (1개)
Cris LaPierre
2021년 2월 23일
편집: Cris LaPierre
2021년 2월 23일
Here's a rought outline.
startY = min(year(data.Var1));
endY = max(year(data.Var1));
for y = startY:endY
ind = year(data.Var1)==y;
plot(day(data.Var1(ind),'dayofyear'),data.Var2(ind))
hold on
end
hold off
댓글 수: 3
Cris LaPierre
2021년 2월 23일
편집: Cris LaPierre
2021년 2월 23일
This solution will work for your data. You just have to load your spreadsheet into MATLAB. I'd use readtable.
data = readtable("data .xlsx",'Sheet','Sheet2')
S.S
2021년 2월 23일
Just combine the two. That's all you need. The readtable function will automatically handle the date for you. This was run in R2020b.
data = readtable("SSdata .xlsx",'Sheet','Sheet2') % I saved your file with this name
startY = min(year(data.Var1));
endY = max(year(data.Var1));
for y = startY:endY
ind = year(data.Var1)==y;
plot(day(data.Var1(ind),'dayofyear'),data.Var2(ind))
hold on
end
hold off
카테고리
도움말 센터 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
