How to plot non-square 3 dimensional matrix?

6 ビュー (過去 30 日間)
Tyler Paladino
Tyler Paladino 2020 年 9 月 28 日
コメント済み: Tyler Paladino 2020 年 9 月 29 日
Hi all,
I have some climate data that I'm having a hard time visualzing in MATLAB. I have 3D temperature matrix with dimensions of 65x49x20. I also have vectors of latitude(49x1), longitude (65x1), and altitude (20x1). I've tried creating a meshgrid out of lat, lon, and altitude, and then scatter3/surf/mesh the meshgrid with the 3D temperature data (e.g. scatter3(xmg,ymg,zmg,T)), but keep running into errors about vectors not being the same length. But everything is the same size! the temp matrix as well as the meshgrid I've created all have the same dimensions, yet I can't seem to be able to plot anything. Anyone have ideas of what I'm doing wrong?
Thanks,
Tyler

採用された回答

Walter Roberson
Walter Roberson 2020 年 9 月 29 日
Example:
%create some data for demonstration
lat = sort(rand(49,1))*180-90;
long = sort(rand(65,1))*360-180;
alt = sort(rand(20,1))*20000;
[latG, longG, altG] = meshgrid(lat, long, alt);
temperature = sort(rand(65,49,20) * 100-50, 3, 'descend');
%now the graphic
pointsize = 20;
scatter3(latG(:), longG(:), altG(:), pointsize, temperature(:))
colorbar
The pointsize is what you missed.
Note that in this, the temperature will not be shown directly, and will instead be encoded as color information.
Alternate graphic:
volshow(temperature, 'colormap', jet);
  1 件のコメント
Tyler Paladino
Tyler Paladino 2020 年 9 月 29 日
Ahh I see. I also forgot to select the whole array (:) in my scatter command. Thanks for your help!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by