2

I want to create a 2d plot of hilbert spectrum. What i want is a time vs frequency plot, where the amplitude of the signal is represented by color changes in the plot.

What i have done is this, but I need it to look like this.

Thank you in advance

EDIT:

I have the values of amplitude and instantaneous frequency over time, that i have produced using Hilbert Huang Transform. Let's say we only use the first IMF, and we have 100 samples. Then what we have is:

    instantaneous_frequency = [f1 f2 f3 ... f100]
    instantaneous_amplitude = [a1 a2 a3 ... a100]
    time = [t1 t2 t3 ... t100]

What i need is a way to plot them like the second image, without using the spectrogram function, since it uses STFT and I have already applied HHT.

The code for producing the first plot is:

Time_Window = 1:101;
signal= rand(1,101);
hilb = hilbert(signal);
inst_amp = abs(hilb);
inst_th = angle(hilb);
inst_freq = diff(a_inst_th)/(1/256)/(2*pi); %instantaneous frequency 
%inst_freq = remove_outliers(inst_freq,Time_Window(1:end-1)); 
inst_freq(end+1) = inst_freq(end); % This is done due to diff()
plot(Time_Window*4,inst_freq,'k.','MarkerSize',5)
achigeor
  • 370
  • 4
  • 12

1 Answers1

0

There is already a MATLAB function to produce a spectrogram, which looks a lot like what you want. See if that solves your problem.

Alex Feinman
  • 5,393
  • 1
  • 30
  • 48
  • Unfortunetly spectrogram uses STFT to find the spectrum. I already have the values of frequency, amplitude and time, that i have produced using Hilbert-Huang Transform. What i need is a way to plot them like the 2nd image. – achigeor Feb 08 '16 at 21:27
  • In that case you can use pcolor: http://www.mathworks.com/help/matlab/ref/pcolor.html Set a colormap appropriately, and you probably don't want an edge color. – Alex Feinman Feb 08 '16 at 21:53
  • Thank you for your answer. I tried using pcolor, but cant make it work. What i do is `pcolor(Time_Window*4,a_inst_freq,diag(a_inst_amp))` and i get is [this](http://i.stack.imgur.com/F9PEh.png). – achigeor Feb 08 '16 at 22:56