Store spectrogram with image data format in the MATLAB workspace
    6 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Daeyeon Koh
 el 4 de En. de 2022
  
    
    
    
    
    Respondida: Star Strider
      
      
 el 4 de En. de 2022
            Hi.
I want to analyze spectrograms of multiple audio files in a folder.
Audio files share the word "SPTGRM" in their names.
Audio files are stereo-type and I will take one channel data.
I saved data in the "AudioData" and also saved spectrogram data of these audio files.
I want to store spectrogram image in the cell with image data format (like [512 512 3]).
However, spectrograms are saved in "complex double" matrix like the figure below.
How can I get image data format?

Address = 'C:\Users\KOH\Desktop\MATLABcode\Soundsample';
Directory = dir(fullfile(Address,'SPTGRM*.wav'));
windowSize = 256;
windowOverlap = [];
freqRange = 1000:20000;
for i = 1:numel(Directory)
    F = fullfile(Address,Directory(i).name);
    [y,Fs] = audioread(F);
    endtime = numel(y)/(2*Fs);
    t = 1/Fs:1/Fs:endtime;
    AudioData{i}=y(:,1);
    Spectrogram{i}=spectrogram(AudioData{i}, windowSize, windowOverlap, freqRange, Fs, 'yaxis');
end
0 comentarios
Respuesta aceptada
Más respuestas (1)
  yanqi liu
      
 el 4 de En. de 2022
        Address = 'C:\Users\KOH\Desktop\MATLABcode\Soundsample';
Directory = dir(fullfile(Address,'SPTGRM*.wav'));
windowSize = 256;
windowOverlap = [];
freqRange = 1000:20000;
for i = 1:numel(Directory)
    F = fullfile(Address,Directory(i).name);
    [y,Fs] = audioread(F);
    endtime = numel(y)/(2*Fs);
    t = 1/Fs:1/Fs:endtime;
    AudioData{i}=y(:,1);
    data=spectrogram(AudioData{i}, windowSize, windowOverlap, freqRange, Fs, 'yaxis');
    Spectrogram{i} = im2uint8(mat2gray(abs(data)));
end
0 comentarios
Ver también
Categorías
				Más información sobre Time-Frequency Analysis en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


