Hi,
I want to add all the signal values between these peaks. For example my first peak is at X = 204 and my second peak is at X =324. I want to add all vales between the interval [ X= 204 to X =324]. Similarly I want to add these values between all the intervals.
[ X = 324 to X = 446]
[ X= 446 to X = 577]
[ X= 577 to X = 698]
[ X= 698 to X = 820]
[ X= 820 to X = 946]
How I can achieve this. Thanks

 채택된 답변

Sudheer Bhimireddy
Sudheer Bhimireddy 2020년 8월 5일

0 개 추천

Use the 'findpeaks' function to get the locations, from there you can find the sum between the indices
[peak_magnitudes,peaks_locs] = findpeaks(your_signal);
If you want the locations in terms of the x-axis variable, use the following:
[peak_magnitudes,peaks_locs_x] = findpeaks(your_signal,your_x_variable);
For finding the sum between the peaks:
% initialize your summation array
signal_peak_sum(numel(peaks_locs)) = 0;
% For the first peak
signal_peak_sum(1) = sum(your_signal(1:peaks_locs(1)));
% For the remaining peaks
for i=2:numel(peaks_locs)
signal_peak_sum(i) = sum(your_signal(peaks_locs(i-1):peaks_locs(i)));
end
Hope this helps.

댓글 수: 2

Tehreem Syed
Tehreem Syed 2020년 8월 5일
Thanks. That was really helpful.
My pleasure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Community Treasure Hunt

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

Start Hunting!

Translated by