Borrar filtros
Borrar filtros

How to get number of peaks and locs from different graphs that are plotted using a single for loop?

2 visualizaciones (últimos 30 días)
figure;
for k=1:length(x)
profile(k)=img(y(k),x(k));
plot(profile,'r-','LineWidth',2);
grid on;
ylim([0 2]);
end
This code giving me different plots. For each of the plot I am getting different peaks. How can individually calculate no of peaks and locs for each of the plot?

Respuestas (1)

KSSV
KSSV el 16 de Jul. de 2018
Have a look on functions max and findpeaks.
  3 comentarios
KSSV
KSSV el 16 de Jul. de 2018
iwant = cell(length(x)) ;
figure;
for k=1:length(x)
profile = img(y(k),x(k));
[pks,locs] = findpeaks(profile) ;
iwant{i} = pks ;
plot(profile,'r-','LineWidth',2);
grid on;
ylim([0 2]);
end
Zara Khan
Zara Khan el 16 de Jul. de 2018
Error using findpeaks Expected Y to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64
Instead its type was logical.
Error in findpeaks>parse_inputs (line 189) validateattributes(Yin,{'numeric'},{'nonempty','real','vector'},...
Error in findpeaks (line 131) [y,yIsRow,x,xIsRow,minH,minP,minW,maxW,minD,minT,maxN,sortDir,annotate,refW] ...
Error in ci_1 (line 33) [pks,locs] = findpeaks(profile);
This is the error I am getting . converting profile to double before using findpeaks still getting the same error

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by