How to get an image of a time frequency representation?

5 views (last 30 days)
Hi, I am trying to compute a time frequency representation plot for a frequency range of 1-60hz. My first issue is that the code below takes a very long time time to compute = 30.7 seconds. Would anyone have any tips to make this more efficient?
tfr=zeros(60,900); % preallocation
for foi=1:60 % frequencies of interest from 1:60
windowsize1=[7*foi]; % 7 cycles foi=window of measurement
tfr(foi, :) = get_amplitude(data,fs,windowsize,foi); % function created to retrieve matrix of amps within this window
end
I then tried to plot this using the image function but get a fully purple plot. But if I just plot the scaling line I get some yellow activity at the lower end of the scale but no details of the data ( I've attached the image of the scaling line plotted). The image I get after plotting tfr eliminates all of the yellow to blue shading.
(p.s. the scaling line was a given so I know that's not the problem).
I have no clue what to change. Am I using some function incorrectly?
figure
image(32+32*tfr./max(max(abs(tfr)))); % scale the tfr
image(tfr)

Answers (1)

Abhishek Ballaney
Abhishek Ballaney on 23 Mar 2018
https://www.mathworks.com/help/signal/ref/spectrogram.html

Community Treasure Hunt

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

Start Hunting!