Why I can't use the function of decimate

조회 수: 12 (최근 30일)
Aminatul Saadiah
Aminatul Saadiah 2020년 7월 1일
댓글: Star Strider 2020년 7월 3일
Hi, I try an example of decimation stated in matlab. But I don't get the result as shown in the example. What should I do? Below shows the result that I run in my matlab. The first image is from the examaple, the second image is the result that I get.
t = 0:1/4e3:1;
x = sin(2*pi*30*t) + sin(2*pi*60*t);
y = decimate(x,4);
subplot(2,1,1)
stem(0:120,x(1:121),'filled','MarkerSize',3)
grid on
xlabel('Sample Number')
ylabel('Original')
subplot(2,1,2)
stem(0:30,y(1:31),'filled','MarkerSize',3)
grid on
xlabel('Sample Number')
ylabel('Decimated')

채택된 답변

Star Strider
Star Strider 2020년 7월 1일
I get the same result as in the documentation (in R2020a).
First, what version of MATLAB are you using? The current online documentaion is for R2020a, however the decimate funciton could have changed over the years.
Second, run this line from a script or your Command Window:
which decimate -all
The only result should be:
C:\Program Files\MATLAB\R2020a\toolbox\signal\signal\decimate.m
or something similar for your version, if it is not R2020a.
  댓글 수: 5
Aminatul Saadiah
Aminatul Saadiah 2020년 7월 3일
I already delete the 'decimate.m' in my current folder. And it works! Thank you
Star Strider
Star Strider 2020년 7월 3일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by