# Finding peaks greater than a set value

3 visualizaciones (últimos 30 días)
HC98 el 13 de Feb. de 2023
Respondida: Image Analyst el 13 de Feb. de 2023
I'm using
for h2 = 1:size(udata,1);
[pks,locs] = findpeaks(udata(h2, :), x);
pksc{h2,:} = pks; % Cell Array Of Peak Values
locsc{h2,:} = locs; % Cell Array Of Location Values
end
Lv = cellfun(@(x)(x < 1.9) & (x > 0.5), pksc, 'Unif',0);
% this line needs to be changed so that we can detect peaks 2*la^2 < peak
% < 0.5, basically isolate the step.
pksm = cellfun(@(x,y)x(y), pksc, Lv, 'Unif',0); % Peak Values Result
locsm = cellfun(@(x,y)x(y), locsc, Lv, 'Unif',0);
to find peaks with amplitudes >= 1.9 but when I run this code, the cell array is just 1x0 empties. Any ideas?
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Star Strider el 13 de Feb. de 2023
Any ideas?
Yes.
None of the identified peaks meet the criteria you set.
See my latest Comment to your earlier post How can I rewrite this to get peak locations? on how to deal with that.
.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Más respuestas (1)

Image Analyst el 13 de Feb. de 2023
I don't think using colon as the second index will work unless pksc and locsc have been preallocated as 1-D vectors. It will not fill out a 2-D matrix with multiple columns with info from one peak in each separate column, like you're probably thinking. Also findpeaks.
pks is an array that may have different number of elements depending on how many peaks were in each row of udata. So it just goes into one cell. See the FAQ: https://matlab.fandom.com/wiki/FAQ#What_is_a_cell_array?
Also, findpeaks has a 'MinPeakHeight' option that you can use to find only peaks higher than a certain value so you can skip the cellfun stuff.
[rows, columns] = size(udata);
% Make a cell array for the output.
ca = cell(rows, 2); % Col 1 = peak values array, col 2 = indexes array.
for row = 1 : rows
[peakValues, indexesOfPeaks] = findpeaks(udata(row, :), 'MinPeakHeight', 0.5);
% Put peak values into column 1 of cell array and
% indexes into column 2 of cell array.
ca{row, 1} = peakValues; % Cell Array Of Peak Values
ca{row, 2} = indexesOfPeaks; % Cell Array Of Location Values
end
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Descriptive Statistics en Help Center y File Exchange.

R2022b

### Community Treasure Hunt

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

Start Hunting!

Translated by