Hi,
This is basic but could not find the solution. I wanted to plot a 3D Bar graph on MATLAB of the following array:
X Y Z
6.50319529000000 10 5
6.50463629000000 10 10
6.50548840000000 10 15
6.50607061000000 10 20
6.26503134000000 12 5
6.26630878000000 12 10
6.26717043000000 12 15
6.26777792000000 12 20
6.01515388000000 14 5
6.01623726000000 14 10
6.01715994000000 14 15
6.01779366000000 14 20
5.74271154000000 16 5
5.74320126000000 16 10
5.74414110000000 16 15
5.74482298000000 16 20
Can someone help me with this?

 採用された回答

Chunru
Chunru 2021 年 9 月 17 日
編集済み: Chunru 2021 年 9 月 17 日

0 投票

xyz=[...
6.50319529000000 10 5
6.50463629000000 10 10
6.50548840000000 10 15
6.50607061000000 10 20
6.26503134000000 12 5
6.26630878000000 12 10
6.26717043000000 12 15
6.26777792000000 12 20
6.01515388000000 14 5
6.01623726000000 14 10
6.01715994000000 14 15
6.01779366000000 14 20
5.74271154000000 16 5
5.74320126000000 16 10
5.74414110000000 16 15
5.74482298000000 16 20];
xq = unique(xyz(:,1));
yq = unique(xyz(:,2));
[xx, yy] = meshgrid(xq, yq);
zz = nan(size(xx));
for k=1:size(xyz, 1)
j = find(xyz(k,1)==xq, 1);
i = find(xyz(k,2)==yq, 1);
zz(i, j) = xyz(k, 3);
end
zz
zz = 4×16
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 5 10 15 20 NaN NaN NaN NaN NaN NaN NaN NaN 5 10 15 20 NaN NaN NaN NaN NaN NaN NaN NaN 5 10 15 20 NaN NaN NaN NaN NaN NaN NaN NaN 5 10 15 20 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
bar3(zz)
xlabel('x');
ylabel('y');
%set(gca, 'XTickLabel', string(xq))
set(gca, 'XTickLabel', num2str(xq, '%.1f'))
set(gca, 'YTickLabel', string(yq))

4 件のコメント

shraddha IV Aero
shraddha IV Aero 2021 年 9 月 17 日
Thank you so much! This was really helpful.
However, now if I want to plot the x axis values on the z axis with axis values in 0.1(5.6 to 6.6) increments. How do I go about it?
Chunru
Chunru 2021 年 9 月 17 日
See above.
shraddha IV Aero
shraddha IV Aero 2021 年 9 月 17 日
編集済み: shraddha IV Aero 2021 年 9 月 17 日
I got it! Thank you so much!
Chunru
Chunru 2021 年 9 月 17 日
Use zlim:
zlim([4 6]) % adjust value

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

その他の回答 (0 件)

カテゴリ

製品

リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by