I used the spectrogram
function in MATLAB to generate spectrogram and save it as a mat file directly. Then, I used the same wav file and the same way to generate another spectrogram. But I saved it as a jpg file first and the saved the jpg file as a mat file. I am confused as to why the matrix sizes in the two mat files are different,the first one is 147*257
double and the second one is 256*256*3
uint8.
%% the first one
[x,fs] = audioread('1.wav')
spectrogram(x, window, L, N, fs);
set(gcf, 'position', [500,500,205,205]);
set(gca, 'Position', [0 0 1 1]);
f = getframe(gcf);
mat = getimage(gcf);
save(['D:\matlab\speech\', strcat(int2str(i)), '.mat'], 'mat', '-v6');
%% the second one
[x,fs] = audioread('1.wav')
spectrogram(x, window, L, N, fs);
set(gcf,'position', [500,500,205,205]);
set(gca,'Position', [0 0 1 1]);
f = getframe(gcf);
mat = getimage(gcf);
imwrite(f.cdata, ['D:\matlab\speech\', int2str(i),'.jpg']);
img_A = imread(fullfile(file_path, strcat(int2str(i), '.jpg')))
save(['D:\matlab\speech\',strcat(int2str(i)), '.mat'], 'img_A', '-v6');
Does anyone know why this happens? How can I properly store spectrogram as mat file?