I'm attempting to generate spectrograms so that I could compare them to word samples later for a very basic speech recognition project. This is being done in a loop. The code is as follows:
folder = '<<my directory path>>';
files = dir(fullfile(folder,'*.wav'));
for k = 1:length(files)
baseFileName = files(k).name;
fullFileName = fullfile(folder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
[word, fs] = wavread(fullFileName);
sound(word, fs);
figure('visible','off');
%%fig = figure, specgram(fullFileName, 512, fs);
%%saveas(fig, baseFileName.fig);
end
My issue is in the last two lines. I want to save the spectrogram figure as a .fig file (unless you guys have a better suggestion for comparison purposes later on) and name it the same as baseFileName. I've been googling for a while now but the formatting is confusing and there isn't much about spectrogram being saved as figures.
I would prefer it if all the figures didn't pop up in the loop but I can deal.
EDIT: perhaps it will be better to store this as a matfile?