Findpeaks Change/Substitute

3 vues (au cours des 30 derniers jours)
Evan Parshall
Evan Parshall le 4 Juin 2023
Modifié(e) : Stephen23 le 5 Juin 2023
I am working with a built in Matlab function, findpeaks. I want to be able to use this function for C/C++ code generation. The main functionality I desired from the findpeaks algorithm is the prominence and location of the peaks. An example line of code is below:
[~,locs,~,prom] = findpeaks(nth_order_mags, 1:length(nth_order_mags), 'MinPeakProminence', .0001);
When I generate code, the device I generate code to does not permit the use variable-size signals or non-finite numbers. It has come to my attention that in order for the findpeaks algorithm to be code generated, these settings must be turned on.
My question is this: can I configure the Matlab findpeaks function to not require variable-size signals and non-finite numbers (it is ok if I have to specify the number of peaks that will be returned before running the function). Are there any alternative functions other than findpeaks that can help me achieve this task of finding peaks and prominences? Thank you
  1 commentaire
Stephen23
Stephen23 le 5 Juin 2023
Modifié(e) : Stephen23 le 5 Juin 2023
"Are there any alternative functions other than findpeaks that can help me achieve this task of finding peaks and prominences?"
Here are some:
Do NOT follow bad advice to modify the inbuilt FINDPEAKS: modifying inbuilt functions is definitely NOT recommended. If you want: take a copy of it, save it with your ownfiles, and give it your own name, e.g. MYFINDPEAKS. Do not use the same name.

Connectez-vous pour commenter.

Réponses (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 4 Juin 2023
  1. You can speficy the base signal around which to find peaks - see peak prominences DOC.
  2. To see and undertand or edit or write your own aalternative findpeaks() function, type in the command window of your MATLAB: edit findpeaks
  3. You can also use fminbnd(), fminsearch(), islocalmin(), isloacalmax(), functions.
  1 commentaire
John D'Errico
John D'Errico le 4 Juin 2023
I'm sorry, but this is IMHO, bad advice. Do NOT edit the findpeaks code!!!!!!
NEVER modify supplied code, unless you are good enough to have written the code in the first place. And even then, see my first statement. You will be sorry if you do, because many bugs are by user edited code.
If you do decide to modify the findpeaks code, then create a NEW version, with your own name. Call it myfindpeaks, or something else.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Get Started with Signal Processing Toolbox dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by