How to set proper configuration to obtain peaks of my data
조회 수: 21 (최근 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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1043115/image.png)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1043120/image.png)
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1043125/image.png)
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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!