Plot of a three dimensional matrix

Suppose I have a three dimensional matrix where the first index is the city, the second index is time. and the third index is temparature. I want to create a plot where the x axis is time. and y axis is the temperature of each city. Please advise how to proceed.

 Accepted Answer

Image Analyst
Image Analyst on 28 Dec 2017
Open the Volume Viewer App
  • MATLAB® Toolstrip: Open the Apps tab, under Image Processing and Computer Vision, click the Volume Viewer app icon. Or...*
  • MATLAB command prompt: Enter volumeViewer.

11 Comments

Thank you. What will be the corresponding code?
volumeViewer does not support passing in coordinate vectors for the coordinates. There would not be any way for passing in meaningful names for the cities.
volumeViewer does support passing in a 4 x 4 reference matrix. That could be used to pass scaling and translation information for the time and temperature matrices.
I would like to understand the code to write in the script. Thank you very much.
volumeViewer(Your3DMatrix)
Image Analyst
Image Analyst on 28 Dec 2017
Edited: Image Analyst on 28 Dec 2017
Wait a minute. This does not seem like a 3-D matrix. If index 1 is the city number, and index 2 is the time index, and index 3 is the temperature index, then what is the value? For example, let's say we're looking at city #2, time point #4, and temperature index of 3. OK, fine, but what is the value stored at data(2, 4, 3)? It's not the temperature because that is the third index. So what is it? Is it the wind speed? Is it the cloud cover fraction? What is it???
OR do you actually have a 2-D array where for each city number and for each time point you have a single temperature? If so, you can simply use imshow() to show that 2-D temperature matrix, applying a colormap if you want. Or you could use surf() if you'd like a 3-D-ish perspective rendering.
I mean, the data is the temperature of a city (LA, NY) in Jan-Dec. The output has temperatures of LA and NY in Y-axis and Jan-Dec in X-axis.
OK, you threw us by calling it a 3-D data situation. What you have is a 2-D situation, NOT 3-D, and you can use 2-D ways of displaying it, like imshow(), imagesc(), image(), or surf().
alpedhuez
alpedhuez on 28 Dec 2017
Edited: alpedhuez on 28 Dec 2017
To be clear, consider the table
NY Jan 30
NY Feb 40
NY Mar 50
LA Jan 40
LA Feb 50
LA Mar 60
Then I want to define a variable LAtemp ={30,40,50} and also I want to have a plot with NY, LA temperature on Y axis and Months on X axis.
Does anyone else understand this, or is it just me? What is LAtemp used for? Does he want a 2-D bar chart? Why not simply extract values for each city and plot them as a function of month?
Yes. My question is "is there a simpler way than 'extract values for each city and plot them as a function of month'"?
The simpler ways of extract the values requires that the same number of months be present for each city and that all of the data for one city be together and sorted by month. In that case, take the temperature column as numeric and reshape() it by the number of entries per city so that all of the entries for one city go into a column. Then you can plot() the 2D array.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!