Matlab 3D bar plot

21 visualizaciones (últimos 30 días)
shraddha IV Aero
shraddha IV Aero el 17 de Sept. de 2021
Editada: shraddha IV Aero el 17 de Sept. de 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?

Respuesta aceptada

Chunru
Chunru el 17 de Sept. de 2021
Editada: Chunru el 17 de Sept. de 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 comentarios
shraddha IV Aero
shraddha IV Aero el 17 de Sept. de 2021
Editada: shraddha IV Aero el 17 de Sept. de 2021
I got it! Thank you so much!
Chunru
Chunru el 17 de Sept. de 2021
Use zlim:
zlim([4 6]) % adjust value

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by