필터 지우기
필터 지우기

max and min in one cycle

조회 수: 3 (최근 30일)
Mohanned Al Gharawi
Mohanned Al Gharawi 2018년 5월 16일
댓글: Mohanned Al Gharawi 2018년 5월 16일
Hi everyone
I have a signal, I need to find max and min values for each cycle in this signal.
Let's say we have the signal A which has two cycles:
Signal=[0 -2 -3 -3.5 -3.25 -2.5 -1.75 -1 0 1 1.8 2.6 3.25 3.5 3.25 2.6 1.7 0 -2 -3 -3.5 -3.25 -2.5 -1.75 -1 0 1 1.8 2.6 3.25 3.5 3.25 2.6 1.7 0]
as shown in the attached picture.
I should get for the first cycle -3.5 and 3.25 and the same values for the second cycles.
Thank you in advance
  댓글 수: 2
Walter Roberson
Walter Roberson 2018년 5월 16일
Perhaps run findpeaks twice, once on Signal and once on -Signal
Mohanned Al Gharawi
Mohanned Al Gharawi 2018년 5월 16일
Thank you for your responding, But I think findpeaks gives us only one value for one signal, while what I want finding max and min values (two values) for the first cycle then the max and min (also two values) for the second cycle and keep going to the last cycle for one signal. Thanks

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

채택된 답변

Image Analyst
Image Analyst 2018년 5월 16일
If you have the Image Processing Toolbox, you can do this:
props = regionprops(Signal < 0, Signal, 'MinIntensity');
minIntensities = [props.MinIntensity]
props = regionprops(Signal > 0, Signal, 'MaxIntensity');
maxIntensities = [props.MaxIntensity]
but I get 3.5 for the maxima. Why are you saying 3.25?
  댓글 수: 1
Mohanned Al Gharawi
Mohanned Al Gharawi 2018년 5월 16일
Yes my mistake it must be 3.5, and the code worked. Thank you so much.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2018년 5월 16일
[maxpk, maxloc] = findpeaks(Signal);
[minpk, minloc] = findpeaks(-Signal);
extremevals = [maxpk.', -minpk.'];
extremlocs = [maxloc.', minloc.'];
>> extremevals
extremevals =
3.5 -3.5
3.5 -3.5
>> extremlocs
extremlocs =
14 4
31 21
  댓글 수: 1
Mohanned Al Gharawi
Mohanned Al Gharawi 2018년 5월 16일
Thanks it works also, I appreciate your help.

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

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by