首页 > 解决方案 > 八度音阶错误:词干:X 和 Y 的大小不一致

问题描述

我要计算一个离散时间傅里叶变换,我正在使用 fft() 和 fftshift()。但是,我遇到了一些错误,我不知道为什么。

这是我的编码。

t = 0:0.005:0.595; 
n = t/0.005;
x = 4*cos(10*pi*t+0.25*pi) + 2*sin(20*pi*t) ;
xlim([0 0.595])
subplot(211) ; plot(t,x)
subplot(212) ; stem(n,x)


X = fft(x)/length(x);

f =-100:100:120;            
P = angle(X).*(abs(X)>0.001);
subplot(211); stem(f,fftshift(abs(X)),'.')
subplot(212); stem(f,fftshift(P),'.')

这是我得到的错误。

>> LAB4

error: stem: inconsistent sizes for X and Y
error: called from
    __stem__>check_stem_arg at line 278 column 11
    __stem__ at line 37 column 49
    stem at line 127 column 8
    LAB4 at line 13 column 15
>>

标签: octave

解决方案


推荐阅读