Matlab 3D bar plot

22 vues (au cours des 30 derniers jours)
shraddha IV Aero
shraddha IV Aero le 17 Sep 2021
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?

Réponse acceptée

Chunru
Chunru le 17 Sep 2021
Modifié(e) : Chunru le 17 Sep 2021
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 commentaires
shraddha IV Aero
shraddha IV Aero le 17 Sep 2021
Modifié(e) : shraddha IV Aero le 17 Sep 2021
I got it! Thank you so much!
Chunru
Chunru le 17 Sep 2021
Use zlim:
zlim([4 6]) % adjust value

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by