Plotting a spectrum-like figure

10 ビュー (過去 30 日間)
Tahmid Chowdhury
Tahmid Chowdhury 2017 年 8 月 17 日
コメント済み: Martin Stump 2019 年 12 月 16 日
Hello, I am aware of the spectrogram function of MATLAB. But I can't use that, and my question is I have three vectors-time, frequency, and energy of each frequency. I want to plot a figure where in x-axis I have time, in y-axis I have frequency and the energy of each frequency is visualized by different colors. Can you please explain how to plot?

回答 (4 件)

Robert U
Robert U 2017 年 8 月 17 日
Hi Tahmid Chowdhury,
From what you are describing you could have a look at contourf() https://de.mathworks.com/help/matlab/ref/contourf.html?s_tid=srchtitle and since there is the need of a grid instead of vectors for x- and y-axis you should have a look at meshgrid() https://de.mathworks.com/help/matlab/ref/meshgrid.html?searchHighlight=meshgrid&s_tid=doc_srchtitle.
Kind regards,
Robert
  1 件のコメント
Robert U
Robert U 2017 年 8 月 17 日
Here just a small example out of matlab:
contourf(peaks(20),256,'LineStyle','none')

サインインしてコメントする。


John BG
John BG 2017 年 8 月 17 日
Hi Tahmid
You don't want to use spectrogram because not enough time lines, right?
Perhaps you would like to use one of the following
1.
[x,y] = meshgrid(-3:.5:3,-3:.1:3);
z = peaks(x,y);
figure;ribbon(y,z)
2.
figure
[X,Y,Z] = peaks(30);
waterfall(X,Y,Z)
3.
Lawrence has built a ceptstral GUI that seems to match the tool needed to compare those 3 time-vectors mentioned in your question
.
download available here
.
4.
https://uk.mathworks.com/matlabcentral/fileexchange/7463-waterfall-fft?s_tid=srchtitle
if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance
John BG

Tahmid Chowdhury
Tahmid Chowdhury 2017 年 8 月 19 日
Hi Robert and John, Thank you for your feedbacks. I certainly did learn new things from you both.
However, what I am looking for is an image like this-(please see attached)
This is basically the plot of- --a time vector --10 column vectors of frequencies, where each column represents frequencies of one intrinsic mode function at time t --10 column vectors of energies, where each column represents the energies of the frequencies of one intrinsic mode function.
I know how to compute these functions and how to calculate the energies and frequencies. But my concern is the plotting.
  2 件のコメント
Tahmid Chowdhury
Tahmid Chowdhury 2017 年 8 月 19 日
PS-just wanted to add, the colormap represents the energy of each frequency.
Robert U
Robert U 2017 年 8 月 23 日
Hi Tahmid Chowdhury,
if you know how to calculate the energy of each frequency at any time than you "just" have to provide the following data:
  • grid X containing the time values,
  • grid Y containing the frequency values
  • grid Z containing the corresponding energy
Then, you can try different plots (some presented in this thread) and choose whichever you like most.
Contour-Plots:
Surface and Mesh Plots:
Spectrogram itself utilizes "surf" ( https://de.mathworks.com/help/matlab/ref/surf.html ; see YourMatlabRootPath\toolbox\signal\signal\spectrogram.m).
Kind regards,
Robert

サインインしてコメントする。


Jan
Jan 2017 年 8 月 21 日
編集済み: Jan 2017 年 8 月 21 日
Perhaps you mean:
time = 0:100; % Test data
freq = 0:30;
data = rand(numel(freq), numel(time)) .^ 2;
surface(time, freq, data, 'EdgeColor', 'none');
colormap(jet)
  2 件のコメント
John BG
John BG 2017 年 8 月 23 日
編集済み: John BG 2017 年 8 月 23 日
It's not this, it's a spectrogram Tahmid asks for.
MATLAB already has the command spectrogram.
Jan
Jan 2017 年 8 月 23 日
Tahmid wrote: "I know how to compute these functions and how to calculate the energies and frequencies. But my concern is the plotting." and he knows spectrogram already.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTime-Frequency Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by