3D bar graph of Z with data in X Y Z array

25 次查看(过去 30 天)
FNU Dhanraj
FNU Dhanraj2021-7-23
评论: FNU Dhanraj ,2021-7-27
Hello,
I am having difficulty creating a 3D bar graph. I have the data in X Y Z array and need a 3d bar graph for Z.

回答(1 个)

Konrad
Konrad 2021-7-23
Hi,
provided that x and y are always positive integers, this may be a good start:
tab = readtable('XYZ_Data.txt');
zarray = zeros(max(tab.Y),max(tab.X)); % you could also use NaNs
lind = sub2ind(size(zarray),tab.Y,tab.X);
zarray(lind) = tab.Z;
bar3(zarray); % you may want to reverse the direction of your z-axis if z is always <0
Note that I assume that there is only 1 z-value per x- & y- coordinate.
Best, Konrad
  7 个评论

请先登录,再进行评论。

标签

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by