How can I detect a peak signal inside a periodic pulse array and generate the waveform like the figure below?

3 visualizaciones (últimos 30 días)
array_pulse = [0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0]
array_signal = [0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0]
expect_Out = [0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
Hello! Guys!
I need help generate the output waveform like the figure above.
I have two array, one is the periodic pulse modulation and the other is the detected signal peak.
When the peak is generated and inside the pulse width at high (which is 1) the output then go high until the falling edge of the pulse array. But when the peak is generated outside the pulse width (like the second peak) then it is 0. And when there is no signal peak inside the pulse width then it all goes 0.
I have thought about it all night. Hope someone can help me process these array! Thank you very much!

Respuesta aceptada

Mathieu NOE
Mathieu NOE el 7 de Sept. de 2022
hello
here you are - hope you will sleep better tonight...
array_pulse = [0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0];
array_signal = [0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0];
expect_Out = zeros(size(array_pulse));
% init
t = 0:numel(array_pulse)-1;
status = 0;
% first sample code
if array_signal(1)>0.5 && array_pulse(1)>0.5
status = 1;
end
if array_signal(1) - 0 <-0.5
status = 0;
end
expect_Out(1) = status;
% second up to last sample code
for ci = 2:numel(array_pulse)
if array_signal(ci)>0.5 && array_pulse(ci)> 0.5
status = 1;
end
if array_pulse(ci) - array_pulse(ci-1) < -0.5
ci
status = 0;
end
expect_Out(ci) = status;
end
figure(1);
subplot(311),plot(t,array_pulse,'b');
subplot(312),plot(t,array_signal,'r');
subplot(313),plot(t,expect_Out,'g');

Más respuestas (0)

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by