3D plotting of boxes using coordinates in CSV file

조회 수: 9 (최근 30일)
Thulasy Chandran
Thulasy Chandran 2023년 12월 19일
댓글: Thulasy Chandran 2024년 7월 9일
hi,
i need help on how to plot the coordinates stored in csv file in a 3D visual.
input CSV file:
expected visual:
the code im working on which is not giving th eexpected output:

채택된 답변

Voss
Voss 2023년 12월 19일
solutionData = [ ...
4 0 0 0 0 15 0 0 0 20 0 15 20 25 0 0 25 15 0 25 0 20 25 15 20; ...
2 25 0 0 25 18 0 25 0 12 25 18 12 33 0 0 33 18 0 33 0 12 33 18 12; ...
3 25 18 0 25 23 0 25 18 14 25 23 14 35 18 0 35 23 0 35 18 14 35 23 14; ...
5 25 0 12 25 12 12 25 0 30 25 12 30 47 0 12 47 12 12 47 0 30 47 12 30; ...
1 25 12 12 25 32 12 25 12 22 25 32 22 40 12 12 40 32 12 40 12 22 40 32 22];
coordinates = solutionData(:, 2:end);
N = size(coordinates,1);
colors = [0 1 0; 0 0 1; 1 0 0; 1 1 0; 1 0 1];
colors = repmat(colors,ceil(N/size(colors,1)),1);
figure
F = [1 2 4 3; 5 6 8 7; 1 2 6 5; 4 3 7 8; 2 6 8 4; 1 5 7 3];
for ii = 1:N
C = reshape(coordinates(ii, :), 3, []).';
patch( ...
'Vertices',C, ...
'Faces',F, ...
'FaceColor','flat', ...
'FaceVertexCData',colors(ii,:), ...
'FaceAlpha',0.5);
end
view(3)
xlabel('X-axis');
ylabel('Y-axis');
zlabel('Z-axis');
title('Visualization of Boxes');
grid on;
  댓글 수: 24
Voss
Voss 2024년 7월 8일
What's wrong with it?
Thulasy Chandran
Thulasy Chandran 2024년 7월 9일
i would like to expand my datasets. i would like to know how can change the boundary box plotting according to it.
dataset 1:
BoxID containerWidth containerLength containerHeight
1 26 34 45
2 28 32 40
3 30 36 44
4 25 35 42
5 32 33 41
6 27 38 46
7 29 39 48
8 31 37 47
9 34 40 43
10 33 31 49
dataset 2:
BoxID containerWidth containerLength containerHeight
1 51 60 70
2 55 62 65
3 53 68 72
4 50 61 66
5 59 64 67
6 57 65 71
7 56 69 74
8 60 66 73
9 54 63 68
10 52 70 75
11 61 67 64
12 58 59 69
13 62 71 63
14 63 72 61
15 64 73 62

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by