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.

 채택된 답변

Star Strider
Star Strider 2022년 8월 23일

0 개 추천

Make them different colours and specify a view angle and it works —
LD = load(websave('hex_3d','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1105925/hex_3d.mat'))
LD = struct with fields:
hex_3d: {182×5 cell}
hex_3d = LD.hex_3d;
hex_3d = 182×5 cell array
{4×1 double} {4×1 double} {4×1 double} {4×1 double} {4×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {8×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {6×1 double} {9×1 double} {9×1 double} {9×1 double} {9×1 double} {9×1 double} {4×1 double} {4×1 double} {4×1 double} {4×1 double} {4×1 double} {4×1 double} {4×1 double} {4×1 double} {4×1 double} {4×1 double}
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

Sierra
Sierra 2022년 8월 23일
Thanks Strider! It perpectly worked.
additionally, I want to make hexagonal column with these 3 patches.
is it possible to do?
I don't want just draw the line because it seems a polyshape or polygon but it's not a polsyshpae or polygon in matlab workspace.
I want the hexagonal column as one polyshape or polygon.
Star Strider
Star Strider 2022년 8월 23일
As always, my pleasure!
I am not certain what result you want with respect to the hexagonal columns. One option would be to use a surf plot, however I am not certain how best to concatenate the cell vectors to create matrices for that.
Sierra
Sierra 2022년 8월 24일
편집: Sierra 2022년 8월 24일
I want to plot like this and I don't want to just draw lines.
for example, i wanna make a patch with 4 red points.
Thanks for keep answering me. Strider.
This is the best I can do —
LD = load(websave('hex_3d','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1105925/hex_3d.mat'))
LD = struct with fields:
hex_3d: {182×5 cell}
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]
x = 1129×2
126.3342 126.3342 126.3343 126.3343 126.3352 126.3352 126.3343 126.3343 126.3452 126.3452 126.3424 126.3424 126.3414 126.3414 126.3436 126.3436 126.3477 126.3477 126.3467 126.3467
y = cell2mat(hex_3d(:,2))*[1 1]
y = 1129×2
37.4611 37.4611 37.4629 37.4629 37.4612 37.4612 37.4596 37.4596 37.4255 37.4255 37.4303 37.4303 37.4324 37.4324 37.4324 37.4324 37.4251 37.4251 37.4233 37.4233
z = [cell2mat(hex_3d(:,3)) cell2mat(hex_3d(:,5))] % Only Need The Upper & Lower Since They All Appear To Be The Same
z = 1129×2
0 1000 0 1000 0 1000 0 1000 0 1000 0 1000 0 1000 0 1000 0 1000 0 1000
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개)

카테고리

태그

질문:

2022년 8월 23일

댓글:

2022년 8월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by