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 个评论
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
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
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
2022-6-27
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)
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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!