max values over specific intervals of a column vector

3 Ansichten (letzte 30 Tage)
Nhi Thangaratnam
Nhi Thangaratnam am 3 Mär. 2021
Kommentiert: Walter Roberson am 11 Mär. 2021
I have a 166250x1 vector where i need to find the maximum value pr every 144 value and create a new vector with these peaks.
i just started to use matlab, so it might be simple, but i cant figure it out.
hope someone can help me
  1 Kommentar
Walter Roberson
Walter Roberson am 3 Mär. 2021
What do you want to do with the group of 74 left over after dividing into groups of 144?
Do you need the locations of the peaks or just the value?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Shiva Kalyan Diwakaruni
Shiva Kalyan Diwakaruni am 11 Mär. 2021
Hi,
you can use movmax(A,k) function which returns an array of local k-point maximum values for Array A, where each maximum is calculated over a sliding window of length k across neighboring elements of A. When k is odd, the window is centered about the element in the current position. When k is even, the window is centered about the current and previous elements. The window size is automatically truncated at the endpoints when there are not enough elements to fill the window. When the window is truncated, the maximum is taken over only the elements that fill the window.
for more information on movmax you can follow the below link
thanks.
  1 Kommentar
Walter Roberson
Walter Roberson am 11 Mär. 2021
I interpreted the requirement as being that they want to divide the data up into disjoint segments of length 144 and take the maximum per segment.
N = 144;
nfull = floor(length(Vector)/N);
lastidx = nfull * N;
localmax = max(reshape(Vector(1:lastidx), N, 1), [], 1);
stump = max(Vector(lastidx+1:end));
localmax(end+1) = stump;

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by