Creating geometries in matlab

Hello all, I want to create a mesh-grid and then assign properties to few of the blocks (4 here ) as in the figure attached. Is it possible to do all these things in MATLAB, and can somebody help me with the commands required for this process.

2 Comments

Thanks for your response
After using vol3d I am getting an output like this
I put a condition as given below.
if (((X_mid(cell)==2.5)&&(Y_mid(cell)==2.5)&&(Z_mid(cell)==2.5)))
A(i,j,k)= 1;
else if (((X_mid(cell)==5.5)&&(Y_mid(cell)==5.5)&&(Z_mid(cell)==5.5)))
A(i,j,k)= 4;
else A(i,j,k) = 0;
end
end
But these are not visible in the form of complete cube. Have I written code correctly? I want my results to be similar as in the above picture.
You have changed your code since your previous post, so I am not sure how you have created your values.

Sign in to comment.

 Accepted Answer

Walter Roberson
Walter Roberson on 21 Jan 2018
As I said in your other question on the same topic, you should be using vol3d v2 from the file exchange. Notice in the documentation:
In cases where voxels can be any RGB color, use: vol3d('CData', cdata); where cdata is an MxNxPx3 array, with RGB color along the 4th dimension. In cases where color and alpha values are highly independent, specify an MxNxP alphamatte as follows: vol3d('CData', cdata, 'Alpha', alpha);
So define a 3d alpha matrix that is 0 for each location where you have no data and 1 for each location you do have data.
Define a 4D matrix containing the color information. If it is easier for your purpose to define a 3d matrix with color index, then it not difficult to use that to index into a color map to produce a 4d matrix for vol3d purposes.

More Answers (0)

Categories

Find more on Graphics Object Properties 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!