3D plotting of boxes using coordinates in CSV file

10 views (last 30 days)
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:

Accepted Answer

Voss
Voss on 19 Dec 2023
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 Comments
Thulasy Chandran
Thulasy Chandran on 9 Jul 2024
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

Sign in to comment.

More Answers (0)

Categories

Find more on Polar Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!