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.
采纳的回答
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 个评论
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
2017-12-28
编辑:Image Analyst
2017-12-28
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().
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.
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
