dsp.ZeroCr​ossingDete​ctor: a confusing error

조회 수: 1 (최근 30일)
parham kianian
parham kianian 2020년 4월 9일
답변: Mehmed Saad 2020년 4월 9일
I am trying to employ dsp.ZeroCrossingDetector to count number of zero crossings of a signal. Consider the following:
x = 0 : pi/180 : 4*pi;
y = sin(x);
zcd = dsp.ZeroCrossingDetector;
n = zcd(y);
release(zcd);
It is expected that size of n be 1*1, that is a sclar, but MATLAB returns n as vector of zeros with the same size as x.
How can I solve this problem?

채택된 답변

Mehmed Saad
Mehmed Saad 2020년 4월 9일
dsp.ZeroCrossingDetector needs column vector as an input while you are feeding it a row vector
take transpose of x
x = (0 : pi/180 : 4*pi).'; %Transpose it(.')
y = sin(x);
zcd = dsp.ZeroCrossingDetector;
n = zcd(y);
release(zcd);

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by