Spectrogram plot without using spectrogram command

9 views (last 30 days)
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

Answers (2)

Wayne King
Wayne King on 31 Oct 2013
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 on 14 May 2018
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;

Categories

Find more on Time-Frequency Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!