MATLAB: Threshold 3D visualisation

3darraycell arrayMATLABvisualisation

Suppose we have a 3D array r(x,y,z) filled with values 1 and 2. 1. How to visualise it into a 3D model? 2. How to visualise only "2" values, i.e. make "1" invisible? Thank you!

Best Answer

Ok, so try this one. It includes a fast way to generate a random array with only 1 or 2 entries.
%generate a 3d-matrix of size 10x5x5 with values 1,2.
R = randi(2,10,5,5);
%define coordinate grid
x = 1:10; y = 1:5; z = 1:5;
[X,Y,Z] = meshgrid(x,y,z);
%detect points with label=1
I1 = R==1;
%plot points with label=1
scatter3(X(I1),Y(I1),Z(I1),'filled');