Patch error when I plot x,y,z

2 Ansichten (letzte 30 Tage)
Sierra
Sierra am 23 Aug. 2022
Kommentiert: Star Strider am 24 Aug. 2022
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.

Akzeptierte Antwort

Star Strider
Star Strider am 23 Aug. 2022
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 Kommentare
Sierra
Sierra am 24 Aug. 2022
Bearbeitet: Sierra am 24 Aug. 2022
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.
Star Strider
Star Strider am 24 Aug. 2022
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.
.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by