matlab 求DTFT编程问题,请教高手哪里错了?function testL = 200; N = 200;w0 = 0.1*pi;w = (0:N-1) * 0.2 * pi / N; % frequency rangen = 0:(L-1);wh = 0.54 - 0.46 * cos(2*pi*n/(L-1)); % Hamming windowxrec = cos(w0 * n);xham = wh .* xrec; % windo

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/26 09:11:51
matlab求DTFT编程问题,请教高手哪里错了?functiontestL=200;N=200;w0=0.1*pi;w=(0:N-1)*0.2*pi/N;%frequencyrangen=0:(L-

matlab 求DTFT编程问题,请教高手哪里错了?function testL = 200; N = 200;w0 = 0.1*pi;w = (0:N-1) * 0.2 * pi / N; % frequency rangen = 0:(L-1);wh = 0.54 - 0.46 * cos(2*pi*n/(L-1)); % Hamming windowxrec = cos(w0 * n);xham = wh .* xrec; % windo
matlab 求DTFT编程问题,请教高手哪里错了?
function test
L = 200; N = 200;
w0 = 0.1*pi;
w = (0:N-1) * 0.2 * pi / N; % frequency range
n = 0:(L-1);
wh = 0.54 - 0.46 * cos(2*pi*n/(L-1)); % Hamming window
xrec = cos(w0 * n);
xham = wh .* xrec; % windowed data
Xrec = abs(dtft(xrec, w)); % DTFT of rectangular data
Xham = abs(dtft(xham, w)); % DTFT of Hamming data
save xrec.dat xrec /ascii;
save xham.dat xham /ascii;
save frec.dat Xrec /ascii;
save fham.dat Xham /ascii;
where
function X = dtft(x, w)
[L1, L] = size(x);
z = exp(-j*w);
X = 0;
for n = L-1:-1:0,
X = x(n+1) + z .* X;
end
%提示错误Error: Function definitions are not permitted in this context.该怎么解决?

matlab 求DTFT编程问题,请教高手哪里错了?function testL = 200; N = 200;w0 = 0.1*pi;w = (0:N-1) * 0.2 * pi / N; % frequency rangen = 0:(L-1);wh = 0.54 - 0.46 * cos(2*pi*n/(L-1)); % Hamming windowxrec = cos(w0 * n);xham = wh .* xrec; % windo

程序没问题啊(除了中间的那个where要删掉),但运行没有什么提示,只产生了几个数据文件,已打包后作为附件上传.