I want to create a 3D matrix

I want to create a 3D matrix A(10*10*10) then subdivide(1*1*1) it and then give some property to few elements(say at (5,6,10)&(6,6,10) A = 5; else A=0;) and then see this.

7 commentaires

Image Analyst
Image Analyst le 20 Jan 2018
This is what I have written so far
del_x = 1; del_y = 1; del_z = 1;%subdivisions of cube
xi = 1:del_x:10; yj = 1:del_y:10; zk = 1:del_z:10; %dimensions of the cube
N = length(xi); P = length(yj); Q = length(zk);
l=1;
% calculating mid ordinates of each cube
for k = 1:Q
for j = 1:P
for i = 1:N
x = xi(i); y = yj(j);z = zk(k);
X_mid(l) = x + del_x/2;
Y_mid(l) = y + del_y/2;
Z_mid(l) = z + del_z/2;
l=l+1;
end
end
end
l=1;
for k = 1:Q
for j = 1:P
for i = 1:N
if (((X_mid(l)==5.5)||(X_mid(l) == 6.5))&&(Y_mid(l)==6.5)&&((Z_mid(l)==3.5)||(Z_mid(l)==10.5)))
A(i,j,k)= 5;
else A(i,j,k) = 0;
end
l=l+1;
end
end
end
Can anyone tell me how I can view my A matrix as a 3D figure
Walter Roberson
Walter Roberson le 20 Jan 2018
Be careful with comparing floating point values using the bit-for-bit equality operator == . Consider using ismembertol() instead.
Walter Roberson
Walter Roberson le 20 Jan 2018
See vol3d in the File Exchange.
Shivangi
Shivangi le 20 Jan 2018
Are you saying vol3d v2 by Oliver Woodford?
Walter Roberson
Walter Roberson le 20 Jan 2018
Sure.
Shivangi
Shivangi le 21 Jan 2018
Modifié(e) : Walter Roberson le 21 Jan 2018
I want an output like this , for this I am making a meshgrid of x,y,z.
Now I want few cubes (4 as given in the figure) to have different values and others remain zero .
Is it possible to do it in MATLAB and generate such type of 3D result? Can you point me how to approach such problem.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by