Coincidence detector in Matlab

How to make coincidence detector on MATLAB In the picture, signal 5 is result of coincidence detector for signal 1 and signal 3
Signal 6 is result of coincidence detector for signal 2 and signal 4.
Thank you.

댓글 수: 2

Matt Kindig
Matt Kindig 2013년 3월 12일
Are you doing this in Matlab itself or Simulink?
Mail Abos
Mail Abos 2013년 3월 13일
just in Matlab

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

 채택된 답변

Matt Kindig
Matt Kindig 2013년 3월 12일
편집: Matt Kindig 2013년 3월 12일

0 개 추천

How about something like this? (I assume all signals are sampled synchronously).
edges1 = find(diff(Signal1) > 0); %get rising edges on Signal 1
edges3 = find(diff(Signal3) > 0); %get rising edges on Signal 3
commonEdges = intersect(edges1, edges3); %these are the indices of the coincident edges.
Note that this assumes that the rising edges are at identical locations. If there is any timing errors, this simple approach won't work.

댓글 수: 2

Mail Abos
Mail Abos 2013년 3월 13일
편집: Mail Abos 2013년 3월 13일
We already try like this, but we get error problem, please help.
dt = 1e-9; % time increment (in seconds)
maxtime = 20e-6; % maximum length of signal (in seconds)
time = 0:dt:maxtime; % time samples (in seconds)
wavelength = 2e-6; % distance between beginning of each pulse
wavewidth = 0.5e-6; % width of each pulse
rectpulse = ones(1,round(wavewidth/dt)); % Define width of rectangle pulse
operator = zeros(size(time)); % Set operator to zeros
operator(mod(time,wavelength)==0) = 0.75; % Place 0.75 at each pulse location
rectsignal = conv(operator,rectpulse); % Convolve rectpulse w/ operator
rectsignal1 = rectsignal(1,1:length(time)); % Remove any extra
subplot(2,1,1); plot(time,rectsignal1);
title('signal1');
dt = 1e-9; % time increment (in seconds)
maxtime = 20e-6; % maximum length of signal (in seconds)
time = 0:dt:maxtime; % time samples (in seconds)
wavelength = 3e-6; % distance between beginning of each pulse
wavewidth = 0.5e-6; % width of each pulse
rectpulse = ones(1,round(wavewidth/dt)); % Define width of rectangle pulse
operator = zeros(size(time)); % Set operator to zeros
operator(mod(time,wavelength)==0) = 0.75; % Place 0.75 at each pulse location
rectsignal = conv(operator,rectpulse); % Convolve rectpulse w/ operator
rectsignal2 = rectsignal(1,1:length(time)); % Remove any extra
subplot(2,1,2); plot(time,rectsignal2);
title('signal2');
edges1 = find(diff(rectsignal1) > 0); %get rising edges on Signal 1
edges3 = find(diff(rectsignal2) > 0); %get rising edges on Signal 2
commonEdges = intersect(edges1, edges3); %these are the indices of the coincident edges
subplot(2,1,3); plot(commonEdges)
Error using subplot (line 308) Index exceeds number of subplots.
Matt Kindig
Matt Kindig 2013년 3월 14일
Is the subplot error you've indicated here your only problem? The error is thrown because
subplot(2,1,3)
attempts to create a 2x1 grid of two subplots. However, you are attempting to call subplot 3 (which does not exist). Change your subplot call to subplot(3,1,3) and it will work.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by