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 Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by