Octave 倍频程错误:杆:X和Y的尺寸不一致

Octave 倍频程错误:杆:X和Y的尺寸不一致,octave,Octave,我要计算一个离散时间傅里叶变换,我使用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;

我要计算一个离散时间傅里叶变换,我使用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
>>

脚本中的
f
是一个1x3向量。其他都是1x120。我不确定您在
f
中实际尝试获取的值,但您的步骤似乎不正确。
f
在脚本中是一个1x3向量。其他都是1x120。我不确定您在
f
中实际尝试获取的值,但您的步骤似乎不正确。