Matlab中,运行程序出现The length of X must match the number of rows of Y是怎么回事?n=0:26;N=32;k=0:1023;xn=[(0:13)+1,27-(14:26)];Xk=fft(xn,1024);X32k=fft(xn,32);x32n=ifft(X32k);X16k=X32k(1:2:N);x16n=ifft(X16k,16);figure;subplot(3,2,1)stem(

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/17 15:46:12
Matlab中,运行程序出现ThelengthofXmustmatchthenumberofrowsofY是怎么回事?n=0:26;N=32;k=0:1023;xn=[(0:13)+1,27-(14:

Matlab中,运行程序出现The length of X must match the number of rows of Y是怎么回事?n=0:26;N=32;k=0:1023;xn=[(0:13)+1,27-(14:26)];Xk=fft(xn,1024);X32k=fft(xn,32);x32n=ifft(X32k);X16k=X32k(1:2:N);x16n=ifft(X16k,16);figure;subplot(3,2,1)stem(
Matlab中,运行程序出现The length of X must match the number of rows of Y是怎么回事?
n=0:26;N=32;k=0:1023;
xn=[(0:13)+1,27-(14:26)];
Xk=fft(xn,1024);
X32k=fft(xn,32);
x32n=ifft(X32k);
X16k=X32k(1:2:N);
x16n=ifft(X16k,16);
figure;
subplot(3,2,1)
stem(n,xn,'.');xlabel('n');ylabel('x(n)');title('三角波序列');axis([0,32,0,20]);
subplot(3,2,2);wk=2*k/1024;
plot(wk,abs(Xk));xlabel('w/π');ylabel('|X(e^j^\omega)|');title('FT[x(n)]');axis([0,1,0,200]);
subplot(3,2,3)
stem(k,abs(X16k),'.');xlabel('k');ylabel('|X_1_6(k)|');title('16点频率采样');axis([0,8,0,200]);
subplot(3,2,4)
stem(0:15,x16n,'.');xlabel('n');ylabel('x16n');title('16点IDFT(X16k)');axis([0,32,0,20]);
subplot(3,2,5)
stem(k,abs(X32k),'.');xlabel('k');ylabel('|X32k|');title('32点频率采样');axis([0,16,0,200]);
subplot(3,2,6)
stem(0:31,x32n,'.');xlabel('n');ylabel('x32n');title('32点IDFT(X32k)');axis([0,32,0,20]);
运行的时候,第三个图出不来,老是显示The length of X must match the number of rows of Y

Matlab中,运行程序出现The length of X must match the number of rows of Y是怎么回事?n=0:26;N=32;k=0:1023;xn=[(0:13)+1,27-(14:26)];Xk=fft(xn,1024);X32k=fft(xn,32);x32n=ifft(X32k);X16k=X32k(1:2:N);x16n=ifft(X16k,16);figure;subplot(3,2,1)stem(
在你的程序里有个小问题:
在画第三个图的时候,横坐标k是1*1024的向量,而纵坐标是X16k是1*16的向量,二者不匹配,不能画图.我把横坐标改成0:15,只有16个数,就可以了.我不知道这样子改对不对,你斟酌.但是,无论如何要把横坐标的数改成1*16的向量.
画第五个图的时候也出现类似情况.
修改后的程序如下:
n=0:26;N=32;k=0:1023;
xn=[(0:13)+1,27-(14:26)];
Xk=fft(xn,1024);
X32k=fft(xn,32);
x32n=ifft(X32k);
X16k=X32k(1:2:N);
x16n=ifft(X16k,16);
figure;
subplot(3,2,1)
stem(n,xn,'.');xlabel('n');ylabel('x(n)');title('三角波序列');axis([0,32,0,20]);
subplot(3,2,2);wk=2*k/1024;
plot(wk,abs(Xk));xlabel('w/π');ylabel('|X(e^j^\omega)|');title('FT[x(n)]');axis([0,1,0,200]);
subplot(3,2,3)
stem(0:15,abs(X16k),'.');xlabel('k');ylabel('|X_1_6(k)|');title('16点频率采样');axis([0,8,0,200]);
subplot(3,2,4)
stem(0:15,x16n,'.');xlabel('n');ylabel('x16n');title('16点IDFT(X16k)');axis([0,32,0,20]);
subplot(3,2,5)
stem(0:31,abs(X32k),'.');xlabel('k');ylabel('|X32k|');title('32点频率采样');axis([0,16,0,200]);
subplot(3,2,6)
stem(0:31,x32n,'.');xlabel('n');ylabel('x32n');title('32点IDFT(X32k)');axis([0,32,0,20]);