Matlab 3D bar plot

조회 수: 13 (최근 30일)
shraddha IV Aero
shraddha IV Aero 2021년 9월 17일
편집: shraddha IV Aero 2021년 9월 17일
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일
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일
편집: 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개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by