Spectrogram plot without using spectrogram command

4 次查看(过去 30 天)
I've analyzed an electric power measurement by calculating its fft and what I have now is a matrix with the columns containing the information for each frequency and the rows contains the information over time. This matrix is called A. A has dimensions m*n.
To this I have a frequency vector f with dimensions with dimensions 1*n and a time vector t with dimensions 1*m.
Which is the simplest way of aquiring the spectrogram plot of A with regards to f and t without using the spectrogram function?
Best regards B

回答(2 个)

Wayne King
Wayne King 2013-10-31
You can use imagesc(), or surf(), for example.
Look at the help for spectrogram(), I realize you are not using spectrogram(), but you can see how to display your data, because spectrogram() outputs time and frequency vectors and a matrix.

Vrushabh Bhangod
Vrushabh Bhangod 2018-5-14
Below attached is an answer to this question. This code takes an audio input and plots its spectrogram without using spectrogram() function customise it accordingly //clc;clear; [y,Fs] = audioread('XXX.wav'); WinD = input('Enter the window time duration:'); WinL = floor(WinD*Fs); % in samples L1 = length(y); y = y(1:L1); shiftD = input('Enter the hop size:');;% hop size in seconds shiftL = floor(shiftD*Fs); nFr = round(length(y)/shiftL); %no., of frames win = hamming(WinL); % hamming preferred for speech input nfft = 1024; STFT = []; for c = 1:nFr - round(WinL/shiftL) % c is the count of frames FB = (c-1)*shiftL+1; % Beginning Frame FE = FB + WinL -1; %Frame End wseg = y(FB:FE).*win; STFT(:,c) = fft(wseg,nfft); end STFTM = abs(STFT(1:nfft/2+1,:)); STFTMdb = 20*log10(STFTM); faxis = (0:nfft/2)*Fs/nfft; naxis = (0:size(STFTM,2)-1)*shiftD; % in seconds STFTMdbmax = max(STFTMdb(:)); dbdown = 60; %deciding the range of the plot caxisl = [STFTMdbmax-dbdown STFTMdbmax];% limiting the range of STFT values imagesc(naxis,faxis,transpose(STFTMdb),caxisl);axis xy; ylabel('Frequency'); xlabel('Length of signal in Seconds'); colorbar;

类别

Help CenterFile Exchange 中查找有关 Time-Frequency Analysis 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by