这是代码:
fs = 22050;
x = rand(fs,1);
x = x - mean(x); % get rid of DC offeset
% set comb-filter coefficients
f = 220; % fundamental
L = round(fs/f); % delay length
coef = 0.99; % IIR coefficient
% build delay vector and filter
b = [1 zeros(1,L-1) coef];
y = filter(1, b, x);
% create amplitude envelope for output
decay = 8;
expEnv = exp ((0:(length(y)-1))/length(y));
expEnv = (1./expEnv).^ decay;
fprintf('%d\n',length(expEnv));
fprintf('%d\n', length(y));
% envelope output signal
z = y .* expEnv;
sound(z , fs); % play sound
它拒绝执行 z = y.*expEnv 行。printf 行显示 y 和 expEnv 的长度相同(22050)