Hi
I have a question about consulting a 3D graph design
I have in my data:
  • Samples
  • Frequency axis
  • And the amplitude by sampling for freq
How would you present this data in a three-dimensional graph
Functions like surf are irrelevant because the Z axis does not depend on X&Y
Z is a known value
tnx :)
Example

5 Comments

Rik
Rik on 13 Nov 2020
What kind of plot do you want? A scatterplot?
What you have presented is data Z with size [32 x 7] at 7 frequencies and 32 "samples", in a plaid frequency-sample grid. For that surf is a reasonably suitable function to illustrate the data, as is pcolor (except for the fact that the last row and column disappears). You could also use scatter, (or plot3).
Unless you can explain why surf is "irrelevant".
First of all thanks for the help
I'm just not sure how to display the graph
In the SURF function I need to multiply the Z axis as a function of XY
for example
Z = sinx * exp (y)
In this case Z is a known value
Is a value I get directly from measuring instruments
I therefore consult how you would present a sub-dimensional surface to this data
Rik
Rik on 13 Nov 2020
You don't need to do that, it is just a way in which you can create some example data. You can just use the actual Z values.
Shahar ben ezra
Shahar ben ezra on 13 Nov 2020
Edited: Shahar ben ezra on 13 Nov 2020
this is work!!
tnx!!

Sign in to comment.

 Accepted Answer

Cris LaPierre
Cris LaPierre on 13 Nov 2020
Edited: Cris LaPierre on 13 Nov 2020

0 votes

I think the natural choice here is a spectrogram. Samples go along one axis, frequency along the other, and color is used to convey power. Look at some of the examples on the linked page.

6 Comments

This is what I was looking for!
But I could not get a graph
Can you see where my error is?
Cris LaPierre
Cris LaPierre on 13 Nov 2020
Edited: Cris LaPierre on 13 Nov 2020
Could you copy/paste your code here? Use the CODE formatting option. You can attach your data using the paperclip icon as well.
%%
clc, clear
my_date = readmatrix('3D PLOT');
vec_x_freq = my_date(1,2:end)
vec_y_samp = my_date(3:end,1)
matrix_z = (my_date(3:end,2:end))
figure(1)
spectrogram(vec_x_freq,vec_y_samp,matrix_z)
Ok, so spectrogram is designed to take in the raw data and extract the frequency content. Your data appears to have already done that. So you really do just need a visualization method.
A simple 2D approach could be heatmap.
my_date = readmatrix("3D PLOT.xlsx");
vec_x_freq = my_date(1,2:end);
vec_y_samp = my_date(3:end,1);
matrix_z = (my_date(3:end,2:end));
figure
heatmap(matrix_z,"XDisplayLabels",vec_x_freq)
colormap parula
If you want a 3D plot, then surf would work, though your data doesn't make that a nice visualization.
figure
s=surf(matrix_z);
s.FaceColor = "interp";
colorbar
Another option might be a 3D bar chart.
figure
bar3(-matrix_z)
zlim([70 100])
xticklabels(vec_x_freq)
xlabel('Frequency')
ylabel('Sample')
zticklabels("-"+zticklabels);
Cris LaPierre
Cris LaPierre on 13 Nov 2020
Edited: Cris LaPierre on 13 Nov 2020
The best way to explore plotting options is to select the variable in your workspace, then open the Plots tab. All possible options for that variable will be displayed. Expand the list to see them all. Find one you like and select it.
Wow
you made my day
Thanks!

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2020b

Community Treasure Hunt

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

Start Hunting!