For creating a cube with plot3d2(.) function it's required to create three matrices for mapping each vertex of the cube.
Think the six faces of the cube, now open them on a plan and hold each vertex position of the cube. Empty elements of the matrix should be filled according spacial logic of the cube, with the same value of the neighbor vertexes.
-->x = [zeros(4, 2), ones(4, 2), zeros(4, 1)]
x =
0. 0. 1. 1. 0.
0. 0. 1. 1. 0.
0. 0. 1. 1. 0.
0. 0. 1. 1. 0.
-->y = ones(4, 5);
-->y(2:3,2:3) = 0
y =
1. 1. 1. 1. 1.
1. 0. 0. 1. 1.
1. 0. 0. 1. 1.
1. 1. 1. 1. 1.
-->z = [zeros(2, 5); ones(2, 5)];
z =
0. 0. 0. 0. 0.
0. 0. 0. 0. 0.
1. 1. 1. 1. 1.
1. 1. 1. 1. 1.
-->plot3d2(x, y, z);
Result is presented in the following image:
In this case, all faces of the cube are equal, which makes this structure symmetric.
Think the six faces of the cube, now open them on a plan and hold each vertex position of the cube. Empty elements of the matrix should be filled according spacial logic of the cube, with the same value of the neighbor vertexes.
-->x = [zeros(4, 2), ones(4, 2), zeros(4, 1)]
x =
0. 0. 1. 1. 0.
0. 0. 1. 1. 0.
0. 0. 1. 1. 0.
0. 0. 1. 1. 0.
-->y = ones(4, 5);
-->y(2:3,2:3) = 0
y =
1. 1. 1. 1. 1.
1. 0. 0. 1. 1.
1. 0. 0. 1. 1.
1. 1. 1. 1. 1.
-->z = [zeros(2, 5); ones(2, 5)];
z =
0. 0. 0. 0. 0.
0. 0. 0. 0. 0.
1. 1. 1. 1. 1.
1. 1. 1. 1. 1.
-->plot3d2(x, y, z);
Result is presented in the following image:
In this case, all faces of the cube are equal, which makes this structure symmetric.
2 comments:
Hey, dude, I have a question for ya, I want to build a 4D matrix, and the forth dimension is for storing information. For example:M is the main matrix,M(:,:,:,1)=1; M(:,:,:,2)=2...
Can you help me?
Hi Jason, excuse me for the late answer, but I have a solution for your problem.
Initialize a variable with zeros(.) function and use the values in sequence like this:
mat = zeros(10, 10, 10, 10);
mat(:;:;:;1) = 1;
mat(:;:;:;2) = 2;
mat(:;:;:;3) = 3;
Best regards.
Post a Comment