フィルターのクリア

Error in findpeaks when trying to find the x corodinate

3 ビュー (過去 30 日間)
Alexander
Alexander 2014 年 12 月 15 日
コメント済み: Maximilian Weber 2018 年 11 月 7 日
Hello,
I have been testing out the "findpeaks" function and have found that when I use:
[pks,locs] = findpeaks(a),
The Y value of the peaks is correct, but the locs value is just the indices.
Then I use
[pks,locs] = findpeaks(a,t)
I get the following error:
Error using findpeaks>parse_inputs (line 131)
Expected a string for the parameter name, instead the input type was 'double'.
Error in findpeaks (line 71)
[X,Ph,Pd,Th,Np,Str,infIdx] = parse_inputs(Xin,varargin{:});
Error in Damping (line 36)
[pks,locs] = findpeaks(a,t);
I have looked online for some solutions and have found that I get the same error when using this script from this thread: http://www.mathworks.com/matlabcentral/answers/158309-how-to-find-the-peaks-both-x-and-y-location
% Create the sample data
x = linspace(0,1,1000);
Pos = [1 2 3 5 7 8]/10;
Hgt = [4 4 4 2 2 3];
Wdt = [2 6 3 3 4 6]/100;
for n = 1:length(Pos)
Gauss(n,:) = Hgt(n)*exp(-((x - Pos(n))/Wdt(n)).^2);
end
PeakSig = sum(Gauss);
plot(x,Gauss,'--',x,PeakSig)
% Use findpeaks with default settings to find the peaks of the signal and their locations.
[pks,locs] = findpeaks(PeakSig,x)
% Plot the peaks using findpeaks and label them.
findpeaks(PeakSig,x)
text(locs+.02,pks,num2str((1:numel(pks))'))
% Sort the peaks from tallest to shortest.
[psor,lsor] = findpeaks(PeakSig,x,'SortStr','descend');
findpeaks(PeakSig,x)
text(lsor+.02,psor,num2str((1:numel(psor))'))
but I still get the same error:
Error using findpeaks>parse_inputs (line 131)
Expected a string for the parameter name, instead the input type was 'double'.
Error in findpeaks (line 71)
[X,Ph,Pd,Th,Np,Str,infIdx] = parse_inputs(Xin,varargin{:});
Error in Testpeask (line 12)
[pks,locs] = findpeaks(PeakSig,x)
does this mean there is something wrong with my matlab?
Thanks for your help
  1 件のコメント
Maximilian Weber
Maximilian Weber 2018 年 11 月 7 日
How did you fix this? I'm also stuck with the same error:
Error using findpeaks>parse_inputs (line 288)
Expected a string scalar or character vector for the
parameter name, instead the input type was 'double'.
Error in findpeaks (line 136)
= parse_inputs(isInMATLAB,Yin,varargin{:});
Error in f0est (line 81)
findpeaks(specdb,npartials,'MinPeakWidth',minpeakwidth,'MaxPeakWidth',maxpeakwidth,...

サインインしてコメントする。

採用された回答

Thorsten
Thorsten 2014 年 12 月 15 日
[pks,locs] = findpeaks(PeakSig);
plot(x, PeakSig)
text(x(locs)+.02,pks,num2str((1:numel(pks))'))
Sorted according to height
[pks ind] = sort(pks, 'Descend');
locs = locs(ind);
text(x(locs)+.02,pks,num2str((1:numel(pks))'))
  5 件のコメント
Alexander
Alexander 2014 年 12 月 15 日
You are amazing. Thank you very much!
Thorsten
Thorsten 2014 年 12 月 15 日
My pleasure :-)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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