counter that will count the input 1. If the input signal goes to 0 then the counter should reset.
조회 수: 1 (최근 30일)
이전 댓글 표시
I have to count every "True" signal and increment the counter by 1, when the signal is "True" and reset the counter to 0 when the signal is "False"
댓글 수: 0
답변 (1개)
Matlab Pro
2024년 6월 4일
Hi
I have created a dummy "signal" variable that gets the value True or False.
Hope this fits your needs
counter = 0;
for i = 1:1000
signal = rand > 0.5;
if signal == 1
counter = counter+1;
else
counter = 0;
end
end
참고 항목
카테고리
Help Center 및 File Exchange에서 Sources에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!