필터 지우기
필터 지우기

To detect the edge of a square wave

조회 수: 15 (최근 30일)
swina
swina 2013년 7월 1일
i have written a code to generate a square wave and to detect its both edges(positive and negative) but it won't work in that manner. pls help me to detect both edges correctly. thanks in advance
t= linspace(0,1,100);
period=0.5;
I=1;
f=0;
p=0;
i_block = 0;
for k = 1:100
t(k)
i_block(k) = mod(t(k)/period, 1) > 0.5;
if i_block(k) > 0 & i_block(k) <=1
p=p+1
else
f=f+1
end;
end;
plot(t, i_block,'r')

답변 (1개)

Image Analyst
Image Analyst 2013년 7월 1일
Try using diff() on the signal and look for +1 or -1.

카테고리

Help CenterFile Exchange에서 Circuits and Systems에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by