这个是matlab的一个代码不知道是哪里出错了,运行不出来,有人能解答吗

% Program2_2
% This program is used to compute the Fourier series coefficients ak of a periodic square wave
clear,close all
T = 2; dt = 0.00001; t = -2:dt:2;
x1 = u(t)-u(t-1-dt); x = 0;
for m = -1:1
x = x + u(t-mT) - u(t-1-mT-dt); % Periodically extend x1(t) to form a periodic signal
end
w0 = 2pi/T;
N = input('Type in the number of the harmonic components N = :');
L = 2
N+1;
for k = -N:1:N;
ak(N+1+k) = (1/T)x1exp(-jkw0*t')dt;
end
phi = angle(ak);
y=0;
for q = 1:L; % Synthesiz the periodic signal y(t) from the finite Fourier series
y = y+ak(q)exp(j(-(L-1)/2+q-1)2pi
t/T);
end;
subplot(221),
plot(t,x), title('The original signal x(t)'), axis([-2,2,-0.2,1.2]),
subplot(223),
plot(t,y), title('The synthesis signal y(t)'), axis([-2,2,-0.2,1.2]), xlabel('Time t'),
subplot(222)
k=-N:N; stem(k,abs(ak),'k.'), title('The amplitude |ak| of x(t)'), axis([-N,N,-0.1,0.6])
subplot(224)
stem(k,phi,'r.'), title('The phase phi(k) of x(t)'), axis([-N,N,-2,2]), xlabel('Index k')

matlab表示变量相乘不能直接写成相连的字母,需要用*连接表示相乘。比如你代码里面的L=2N+1,正确的写法应该是L=2 * N+1
希望点个采纳,谢谢