Counting amoutn of pulses

조회 수: 1 (최근 30일)
Hans Vertongen
Hans Vertongen 2016년 4월 15일
답변: Baltam 2016년 4월 15일
Hello,
I'm using a GUI to two signals of pulses (normally there are much more blue pulses):
Now I need to know how much blue pulses there are before (or after) the red pulse.
Does anyone have an idea?
With Regards
  댓글 수: 1
Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 15일
How did you get this figure?

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

답변 (1개)

Baltam
Baltam 2016년 4월 15일
An easy way would be using the fact that your data makes jumps. If you have the data in vectors. You could try the same as in following example.
redpulse = zeros(50,1);
redpulse(34:35) = 5; % Make one pulse with amplitude 5
bluepulse = zeros(50,1);
bluepulse(2:3:end) = 5;
bluepulse(3:3:end) = 5; % Lots of pulses
hold all,
stem(redpulse,'*'), stem(bluepulse) % Display pulses
ind_redpulse = find(diff(redpulse)>2.5); % Find the index of the first pulse
logical_ind_bluepulses = (diff(bluepulse)>2.5); % find logical vector for all blue pulses
numberOfPulses = sum(ind2(ind_redpulse:end)) % Sum all blue pulse events after the first red one.
Kind regards, Baltam

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by