fall time of square wave

Hi everyone... I want to know the time that my pulses goes 0 (the red points) what is the best way to do that.

Respuestas (2)

Azzi Abdelmalek
Azzi Abdelmalek el 1 de Mayo de 2016

1 voto

If y is your signal
idx=strfind(y,[1 0])

1 comentario

m b
m b el 2 de Mayo de 2016
Editada: m b el 2 de Mayo de 2016
Dear Azzi
Thanks for your answer, but it did not work. I wrote sth but I want to know if there is another easy and best way
this is what i wrote
for i=1:length(y);
z= find ( y==0 );
end
for i=1:16:length(z);
zz=z(i)
hold on
plot (zz,y(zz),'g*')
end and i got this (red stares)

Iniciar sesión para comentar.

Stephen23
Stephen23 el 2 de Mayo de 2016
Editada: Stephen23 el 2 de Mayo de 2016

0 votos

Try this:
N = 200;
% fake data:
vec = ones(1,N);
vec(randperm(N,5)) = 0;
% detect zeros:
idx = diff(vec)<0;
plot(1:N,vec,'-b',find(idx),vec(idx),'r*')
You will also need to decide what happens with leading zeros: I have not taken them into account in this algorithm.

2 comentarios

m b
m b el 2 de Mayo de 2016
Dear stephen, thanks for your answer.
John BG
John BG el 2 de Mayo de 2016
Stephen's answer finds the red dots, but when you write 'know the time that my pulses goes 0 (the red points)' do you mean you want dt1+dt2+dt3+dt4 of the initial signal?
The transitions are not vertical, check the blue arrows.
Do you want to know know much time the signal is stuck on 0?

Iniciar sesión para comentar.

Preguntada:

m b
el 1 de Mayo de 2016

Comentada:

el 2 de Mayo de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by