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

조회 수: 2 (최근 30일)
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?

답변 (1개)

KSSV
KSSV 2018년 7월 16일
Have a look on functions max and findpeaks.
  댓글 수: 3
KSSV
KSSV 2018년 7월 16일
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 2018년 7월 16일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by