How to set proper configuration to obtain peaks of my data

9 views (last 30 days)
Hi!
I want to extract peaks from my response spectrum for the future modal combination alalysis. My spectras have the following image if I use findpeaks command (this graphic is pretty dominant for one frequency, some others may have different form)
:
I´ve considered using the next settings:
findpeaks(F(:,2),F(:,1),"MinPeakHeight",5,"MinPeakDistance",2)
In this case the results are the following which is what I actually want
Nevertheless, if I change the previous line slightly changing the peak distance I no longer capture the main peak
findpeaks(F(:,2),F(:,1),"MinPeakHeight",5,"MinPeakDistance",1)
Instead it captures one of the first peaks of the data. My question is, how can I configure it so it only captures one peak for a certain X interval and this peak always being the highest value there? As I already mentiones, I have quite a few data sets to analyze and I´d like to make it less manual and avoid changing settings for each case.
Tnank you!
  3 Comments
Mathieu NOE
Mathieu NOE on 23 Jun 2022
I like to be challenged ... do you have some files with a few representative data ?
... I'd like to see what I can obtain.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 23 Jun 2022
It would help to have some representative data.
However, since the data are resonances, and the desired result seems to indicate that the peaks are possibly integer harmonics of the greatest peak, one way to approach this is first to take tha max of the data (returning the maximum and its index), and then use the x-value of the maximum (or the index of the maximum, depending on your findpeaks call) to set the 'MinPeakDistance' parameter, perhaps a 90% or so of the x-value or the index value. (Using 'MinPeakProminence' to define the peaks in noisy data might also be an option, however the data do not appear to have much noise. It would be necessary to experiment with that option.)
This involves finding the maximum and its index before calling findpeaks, however that might be the easiest way to get the desired result.
  11 Comments
Star Strider
Star Strider on 27 Jun 2022
That is actually straightforward using the interp1 function:
Freaction = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1043710/Freaction.xlsx');
ModeFreqs = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1046865/modes.xlsx');
%% Imaginary to real
Fcomplex=Freaction(:,2)+i*Freaction(:,3); %complex reactions
Fvalue=abs(Fcomplex); % magnitude
F=[Freaction(:,1) Fvalue];
[pks,locs] = findpeaks(F(:,2), 'MinPeakProminence', 5);
Freqs = F(locs,1);
Amplitudev = interp1(F(:,1), F(:,2), ModeFreqs);
Mode_Amplitude = table(ModeFreqs, Amplitudev)
Mode_Amplitude = 10×2 table
ModeFreqs Amplitudev _________ __________ 1.3421 11.299 3.6806 16.174 3.9112 5.9781 3.9429 7.1333 4.9696 55.494 5.1433 59.957 5.3496 74.118 6.2745 37.595 6.4024 28.312 6.8875 14.667
figure
plot(F(:,1), F(:,2))
hold on
plot(F(locs,1), pks, '^r')
hold off
grid
fpos = get(gcf, 'Position');
set(gcf, 'Position', fpos+[-50 -100 300 200]); % Stretch Limits To Inprove Readability
% text(F(locs,1), pks, compose('A = %6.1f\nF = %4.1f Hz',[pks, F(locs,1)]), 'Horiz','center', 'Vert','bottom')
text(ModeFreqs, Amplitudev, compose(' \\leftarrow F = %4.1f Hz, A = %6.1f',[ ModeFreqs, Amplitudev]), 'Horiz','left', 'Vert','middle', 'Rotation',90, 'FontSize',8)
The figure is a bit difficult to read because some of the mode frequencies are close together.
.

Sign in to comment.

More Answers (1)

Andriy Voshchenko
Andriy Voshchenko on 27 Jun 2022
That is the best solution so far for spedctras which excitate a lot of modes, Thank you @Star Strider!
Depending on the case I guess I can use a simple findpeaks or a more sophisticated solution you provided.
Also, @Mathieu NOE, answering your questions: you find all the peaks for all the modes and simply filter them (set some minimum frequency and don´t count the results below it) and yeah, I´m aware of the matching problem, there is nothing to do with it since its due to the structural damping and that is where I want the solution actually, to obtain the max value which is close to my freq and not just value for the response for that freq.
I guess with all the info you guys provided I can keep going without problem, thanks a lot!

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!