Specgram zooms when sampling rate resampled to lower
Mostra commenti meno recenti
Hello,
I ve an audio wav file(original.wav) with 48000Hz sampling rate. I created spectrogram graph by using this command line:
[y,fs]=audioread('original.wav')
specgram(y)

after than i resampled my file and i did same method:
[a,b]=resample_number('i_wovel.wav',5500)
specgram(y)
%%
%my resample function:
function [y_new,Fs_new]=resample_number(audio_file,Fs_value)
% Code to read audio files
[y,Fs] = audioread(audio_file);
% code to resample audio
Fs_new = Fs_value;
% Take ratio from our old sample
[Numer, Denom] = rat(Fs_new/Fs);
y_new = resample(y, Numer, Denom);
end
After execution, this graph shown:

Why its look like zoomed. Shouldnt it be between same axis. How can i window this to same axis like original one?
3 Commenti
Mathieu NOE
il 25 Mar 2021
hello
yiu mean same x axis ?
the y axi is normalized to Nyquist frequency so 1 = Fs/2
your x axis is by default in samples (and not in seconds) , so when you resample, the output signal samples are reduced , but the duration remains the same
convert your x axis to "true" time to get always same x axis
Altemur Çelikayar
il 25 Mar 2021
Mathieu NOE
il 25 Mar 2021
see code example in the answer section
I use decimate to resample the data to a new Fs then the time vector is updated based on new Fs and amount of samples
%% decimate (if needed)
% NB : decim = 1 will do nothing (output = input)
decim = 1;
if decim>1
signal = decimate(signal,decim);
Fs = Fs/decim;
end
samples = length(signal);
time = (0:samples-1)*1/Fs;
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Multirate Signal Processing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!