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.

 Réponse acceptée

Image Analyst
Image Analyst le 28 Déc 2017

0 votes

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 commentaires

alpedhuez
alpedhuez le 28 Déc 2017
Thank you. What will be the corresponding code?
Walter Roberson
Walter Roberson le 28 Déc 2017
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.
alpedhuez
alpedhuez le 28 Déc 2017
I would like to understand the code to write in the script. Thank you very much.
volumeViewer(Your3DMatrix)
Image Analyst
Image Analyst le 28 Déc 2017
Modifié(e) : Image Analyst le 28 Déc 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.
alpedhuez
alpedhuez le 28 Déc 2017
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.
Image Analyst
Image Analyst le 28 Déc 2017
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 le 28 Déc 2017
Modifié(e) : alpedhuez le 28 Déc 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.
Image Analyst
Image Analyst le 28 Déc 2017
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?
alpedhuez
alpedhuez le 28 Déc 2017
Yes. My question is "is there a simpler way than 'extract values for each city and plot them as a function of month'"?
Walter Roberson
Walter Roberson le 28 Déc 2017
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by