Adding the signal in a specific interval

12 ビュー (過去 30 日間)
Tehreem Syed
Tehreem Syed 2020 年 8 月 5 日
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 日
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.
Sudheer Bhimireddy
Sudheer Bhimireddy 2020 年 8 月 5 日
My pleasure.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by