How to set proper configuration to obtain peaks of my data

13 次查看(过去 30 天)
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 个评论
Andriy Voshchenko
Andriy Voshchenko 2022-6-23
Smoothing a data isn´t really an option since it reduces the peaks amplitude significally (thos peaks are response for the resonance and i don´t want to "smoothe" them), I just want it to capture the max value in each interval, is it possible?
Increasing peak distance is kinda lazy solution because it works in this case but my natural frequencies are 1.3, 2.6, 3.7. 3.9, etc......... Depending on load case I may have peaks as close as 1Hz, I need to tell the programm to somehow retain only the max one.
The other solution is to create a "for" loop and try to extract peaks in predefined intervals but I don´t really like this solution neither because of the probability of it not detecting/detecting extra peaks depending on my intervals separation.
Mathieu NOE
Mathieu NOE 2022-6-23
编辑:Mathieu NOE 2022-6-23
I like to be challenged ... do you have some files with a few representative data ?
... I'd like to see what I can obtain.

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2022-6-23
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 个评论
Mathieu NOE
Mathieu NOE 2022-6-27
hello again
the coding is not complicated but I'm worried that the list of modes is much longer than the number of peaks present in the response spectra as computed by @Star Strider
what do we do with the extra ones ? also the "matching" is not super good between spectra values and modes values
Star Strider
Star Strider 2022-6-27
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.
.

请先登录,再进行评论。

更多回答(1 个)

Andriy Voshchenko
Andriy Voshchenko 2022-6-27
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!

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by