Calculate values from data to monthly

1 Ansicht (letzte 30 Tage)
Ancalagon8
Ancalagon8 am 11 Dez. 2022
Bearbeitet: Ancalagon8 am 6 Jan. 2025
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?

Akzeptierte Antwort

Mathieu NOE
Mathieu NOE am 12 Dez. 2022
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 Kommentare
Ancalagon8
Ancalagon8 am 13 Dez. 2022
Thanks a lot!
Mathieu NOE
Mathieu NOE am 13 Dez. 2022
My pleasure !

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by