Patch error when I plot x,y,z
조회 수: 2 (최근 30일)
이전 댓글 표시
I wanted to plot the patch. but the 'z' value returns only zero in plot.
I want to plot 3 patches with same x,y value. only 'z' value changes
I attach the data and the code.
for i = 1:length(hex_3d)
patch(hex_3d{i,1},hex_3d{i,2},hex_3d{i,3});
hold on
patch(hex_3d{i,1},hex_3d{i,2},hex_3d{i,4});
patch(hex_3d{i,1},hex_3d{i,2},hex_3d{i,5});
end
Please Let me know how to solve this problem.
Thanks.
댓글 수: 0
채택된 답변
Star Strider
2022년 8월 23일
LD = load(websave('hex_3d','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1105925/hex_3d.mat'))
hex_3d = LD.hex_3d;
figure
hold on
for i = 1:length(hex_3d)
patch(hex_3d{i,1},hex_3d{i,2},hex_3d{i,3},'b');
patch(hex_3d{i,1},hex_3d{i,2},hex_3d{i,4},'g');
patch(hex_3d{i,1},hex_3d{i,2},hex_3d{i,5},'r');
end
hold off
grid on
view(30,30)
.
댓글 수: 4
Star Strider
2022년 8월 24일
This is the best I can do —
LD = load(websave('hex_3d','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1105925/hex_3d.mat'))
hex_3d = LD.hex_3d;
% figure
% hold on
% for i = 1:length(hex_3d)
% patch(hex_3d{i,1},hex_3d{i,2},hex_3d{i,3},'b')%, 'EdgeColor','none');
% patch(hex_3d{i,1},hex_3d{i,2},hex_3d{i,4},'g')%, 'EdgeColor','none');
% patch(hex_3d{i,1},hex_3d{i,2},hex_3d{i,5},'r')%, 'EdgeColor','none');
% end
% hold off
% grid on
% view(30,30)
x = cell2mat(hex_3d(:,1))*[1 1]
y = cell2mat(hex_3d(:,2))*[1 1]
z = [cell2mat(hex_3d(:,3)) cell2mat(hex_3d(:,5))] % Only Need The Upper & Lower Since They All Appear To Be The Same
figure
surf(x, y, z, 'EdgeColor','k')
grid on
view(30,45)
colormap(summer)
% shading('interp')
There appear to be a lot of extra horzontal lines and some incomplete ‘columns’ (they look like basalt columns to me), however since I do not understand the data, I am not certain how to eliminate them, or otherwise deal with them.
.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Polygons에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!