Calculate values from data to monthly

조회 수: 1 (최근 30일)
Ancalagon8
Ancalagon8 2022년 12월 11일
편집: Ancalagon8 2025년 1월 6일
I have a timetable and I want to find how many values are equal to 1 for every class. Right now the code calculates the ones for beginning:
How can I create a loop for all the other classes?

채택된 답변

Mathieu NOE
Mathieu NOE 2022년 12월 12일
hello
well a simple for loop will do the job
your result in now an array of length 12 : Max_conseq
load('events.mat')
for m =1:numel(events) % loop over month
f= find(diff([0; events{m} ; 0]==1));
events_this_month= [f(1:2:end-1) f(2:2:end)-1 (f(2:2:end)-1-(f(1:2:end-1))+1)];
Max_conseq(m) = max(events_this_month(:,3));
end
  댓글 수: 3
Ancalagon8
Ancalagon8 2022년 12월 13일
Thanks a lot!
Mathieu NOE
Mathieu NOE 2022년 12월 13일
My pleasure !

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by