Applying bandstop filter to multiple files
Show older comments
How can I write a loop code to filter out 20-150 Hz band from multiple audio files before taking the spectrograms?
The code is as follows:
% load and take specs of COPD
cd('C:\Users\User\Desktop\uni\II semester\DSP\RESPDATA\COPD');
files = dir;
count = 0;
for i = files'
if length(i.name) > 4 && i.name(end-3:end) == ".wav" % only read file if filename is greater then four and extension is '.wav'
count = count+1;
[f{count} fs{count}] = audioread(i.name);
count101{1,count} = (i.name(1:3));
end
end
for ii=1:numel(f)
spectrogram(f{1,ii},'yaxis');
colorbar('off')
set(gca,'Visible','off')
baseFileName = sprintf('Image # %d.png', ii);
fullFileName = fullfile('C:\Users\User\Desktop\uni\II semester\DSP\specs\A', baseFileName);
saveas(gcf, fullFileName);
end
Accepted Answer
More Answers (0)
Categories
Find more on Time-Frequency Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!