MATLAB Answers

rabbasi
0

change in size of STFT output after denoising and error in ISTFT

Asked by rabbasi
on 2 Apr 2017
Latest activity Edited by rabbasi
on 2 Apr 2017
I have a signal with 498900 sample in time, in denoising procedure I removed an interval of frequency from the signal spectrogram. Now, I want to return the spectrogram data to the time scale. I used this code ISTFT
but the problem is that it reports a dimension error,"Matrix dimensions must agree." and as I check that is because of changing the frequency dimension. what can I do?
data and the example code is as below:
if true
[y,Fs] = audioread('16-2014 - Copy.wav');
wlen=625;h=125;window='hamming';nfft=625;h_time=0.5;
frequency_resolution=300;
f=[30000:frequency_resolution:120000];
y=y/(max(abs(y)));
[s, f, t] = stft(y, wlen, h, nfft, Fs);
s=abs(s);
if rem(nfft, 2) % odd nfft excludes Nyquist point
s(2:end, :) = s(2:end, :).*2;
else % even nfft includes Nyquist point
s(2:end-1, :) = s(2:end-1, :).*2;
end
frequency_resolution=Fs/nfft;min_frequency=30000;max_frequency=120000;
min_frequency_index = 76;
max_frequency_index = 301;
s_new=s(min_frequency_index :max_frequency_index,:);
[yd, td] = istft(s_new, h, nfft, Fs);
plot(td,y);hold on;plot(td,yd','r')
end
the STFT and ISTFT functions are in above link. And that is the error: Matrix dimensions must agree.

  0 Comments

Sign in to comment.

0 Answers