所以,我正在研究我的文凭 rn,主题是关于音频文件上的小波以及用它执行的一些操作。所以我必须建立一个绝对系数的积木图,如下图所示: 但我还是坚持了下来。 RN 我正在绘制分解水平。这是我现在的代码:
% load file
[y, fs] = audioread('audiofile.wav');
% max length is 3 sec
max_len = 3 * fs;
if length(y) > max_len
y = y(1:max_len);
end
% wavelet transform
wname = 'coif4'; % wavelet type
level = 5; % decomposition levels
[c, l] = wavedec(y, level, wname);
% visualisation
figure;
for i=1:level+1
subplot(level+1, 1, i);
if i == level+1
plot(1:length(y), y, 'r');
title('Waveform');
else
plot(1:l(i), c(sum(l(1:i-1))+1:sum(l(1:i))), 'b');
title(['Approx coeffs ' num2str(i-1)]);
end
xlabel('Samples');
end
% retrieving signal
rec = waverec(c, l, wname);
soundsc(rec, fs);
% saving reconstructed signal
audiowrite('reconstructed_audiofile.wav', rec, fs);
某处说我应该使用 WTC 函数,但 matlab 不知道它。