用matlab,提示错误??? Error: File: D:\m\work\Untitled.m Line: 16 Column: 26 Missing MATLAB operato

程序如下,帮忙看看怎么改
n=[0:1:10];
x=cos(0.48*pi*n)+cos(0.52*pi*n);
figure(1)
n1=[0:1:9];
y1=x(1:1:10);
subplot(2,1,1);
stem(n1,y1);title('signal x(n),0<=n<=9');xlabel('n')
Y1=fft(y1);magY1=abs(Y1(1:1:6));
k1=0:1:5;
w1=2*pi/10*k1;
subplot(2,1,2);stem(w1/pi,magY1);title('Samples of DTET Magnitude');
xlabel('frequency in pi units')
axis([0,1,0,10])

figure(2)
n3=[0:1:99];y3=[x(1:1:10)zeros(1,90)];
subplot(2,1,1);stem(n3,y3);title('signal x(n),0<=n<=9+90 zeros');
xlabel('n')
axis([0,100,-2.5,2.5]);
Y3=fft(y3);magY3=abs(Y3(1:1:51));
k3=0:1:50;
w3=2*pi/100*k3;
subplot(2,1,2);stem(w3/pi,magY3);title('DTFT Magnitude');
xlabel('frequency in pi units')
axis([0,1,0,10])
x(n)
figure(3)
n=[0:1:99];
x=cos(0.48*pi*n)+cos(0.52*pi*n);
subplot(2,1,1);
stem(n,x);title('signal x(n),0<=n<=99');xlabel('n')
axis([0,100,-2.5,2.5])
X=fft(x);magX=abs(X(1:1:51));
k=0:1:50;
w=2*pi/100*k;
subplot(2,1,2);
stem(w/pi,magX);title('DTFT Magnitude');
xlabel(‘frequency in pi units')
axis([0,1,0,60])

第1个回答  2013-05-22
n3=[0:1:99];y3=[x(1:1:10)zeros(1,90)]; 这句缺个空格
改成
n3=[0:1:99];y3=[x(1:1:10) zeros(1,90)];
第2个回答  2013-05-23
我发现了三处错误
1. xlabel(‘frequency in pi units') 有中文左括号,中文单引号
2. 就是二楼说的,zeros前面有个逗号或者空格
3. x(n),我不知道你的目的。 你n=[0:1:10]; x(0) matlab没有的,下标从1开始本回答被提问者采纳