Does findpeaks only provide one output?
古いコメントを表示
Hi,
I am trying to use the function findpeaks to extract the magnitude, location and width of peaks in my timeseries data (Find local maxima - MATLAB findpeaks (mathworks.com)).
reading MATLAB's documentation, the function should provide four outputs, and I have found several entries and blog posts that suggest using this function to find all three parameters I need. However if I write it like the documentation suggests (i.e., [pks,locs,w,p] = findpeaks(data1)) I am returned the following error: Error using findpeaks. Too many output arguments.
Indeed, if I look up the function in Matlab the description doesn't match that of the documentation and says this function only returns one output:
help findpeaks
Helper function to find peaks in a given continuous valued time series x
Usage: xmax=chron_findpeaks(data,threshold)
Input:
data (data in time x channels/trials form or a single vector)
threshold (if specified returns locations of peaks at which data exceeds threshold) - optional
Output:
xmax (locations of local maxima of data in a structure array of dimensions channels/trials)
Any help? Am I using the wrong function?
採用された回答
その他の回答 (2 件)
dpb
2022 年 11 月 14 日
移動済み: Image Analyst
2022 年 11 月 14 日
You apparently have downloaded either another function or app that has aliased the MathWorks-distributed findpeaks routine. The "helper function" thing gives it away. That's a VERRRY rude thing for anybody to do...
Use
which -all findpeaks
to find the offender; the real one resides in the
>> which -all findpeaks
C:\ML_R2020b\toolbox\signal\signal\findpeaks.m
C:\ML_R2020b\toolbox\signal\signal\@dspdata\findpeaks.m % dspdata method
>>
arena where your install folder will show up in place of "ML_R2020b" here that I use for each release...
Image Analyst
2022 年 11 月 14 日
0 投票
It can return 4 outputs if you ask for 4. You either are asking for more, or you've redefined findpeaks(). Your m-file is not called findpeaks.m is it? Show you ACTUAL error message -- ALL the red text, not just a snippet of the docuementation followed by a snippet of the error message.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
カテゴリ
ヘルプ センター および File Exchange で Descriptive Statistics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!