Spectrogram plot without using spectrogram command
조회 수: 5 (최근 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
댓글 수: 0
답변 (2개)
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.
댓글 수: 0
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;
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Time-Frequency Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!