Creating a loop for finding max value from a specified range
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Jamie Mcwilliam
il 24 Feb 2017
Commentato: Jamie Mcwilliam
il 24 Feb 2017
Hi all,
I have a vector with 8352 rows and I want to find the max value from each consecutive 288 rows, e.g 1:288, 289:577 etc. So I should end up with 29 max values
I am struggling with making a for loop with this
The vector size will change of course depending on the dataset I am using so need to account for this when reusing the loop
Thanks
0 Commenti
Risposta accettata
Jan
il 24 Feb 2017
Modificato: Jan
il 24 Feb 2017
x = rand(8352, 1);
x = reshape(x, 288, []);
y = max(x, [], 1);
And if the length is not a multiple of the window size:
Win = 288;
Len = size(x, 1);
LenP = Len - mod(Len, Win);
x = reshape(x(1:LenP), 288, []);
y = max(x, [], 1);
yRest = max(x(LenP:Len), [], 1);
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Dates and Time in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!