필터 지우기
필터 지우기

Determine the start and end of a vector.

조회 수: 20 (최근 30일)
Ferd
Ferd 2016년 9월 27일
댓글: Ferd 2016년 9월 28일
When the variable starts incrementing above a threshold, that index is to be determined and also when the same variable starts decrementing below a certain threshold, the index is to be determined.
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 9월 27일
Are the two thresholds the same value?
Ferd
Ferd 2016년 9월 28일
Two different thresholds

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

채택된 답변

Image Analyst
Image Analyst 2016년 9월 28일
Try using diff() and strfind():
% Create random sample data.
v = randi(9, 1, 20)
thresh = 3; % Define the threshold.
% Find indexes where v is at or above the threshold.
d = (v>=thresh)
% Find the starting index where the signal starts above the threshold
% and then starts to fall below the threshold.
fallsBelow = strfind(d, [1, 0])
% Find the starting index where the signal starts below the threshold
% and then starts to rise above the threshold.
risesAbove = strfind(d, [0, 1])
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 9월 28일
This is a good approach when the thresholds are the same. Matters get more complicated when the thresholds are different. For example if you wanted to trigger at 1/4 Volt and to keep monitoring until you dropped to 0 V, then it becomes trickier.
Ferd
Ferd 2016년 9월 28일
Thanks! Yeah, had just set it up with two separate thresholds, d1 and d2. Its giving the results I'm looking for!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by