elem(8,8,8) = zeros;
for i=1:8
elem(i,i,i)=1
end
I want to plot 3D voxels or mesh or elements with different color for 1 and different color for 0. How to do that?

 채택된 답변

Walter Roberson
Walter Roberson 2022년 4월 29일

0 개 추천

I did not get around to gettting color working, but you can hardcode facecolor options into the patch() call.

댓글 수: 6

ac_bm_mat
ac_bm_mat 2022년 4월 29일
Can you please tell me what are x,y,z: It is centre of each voxel?
Walter Roberson
Walter Roberson 2022년 4월 29일
That code is aimed at creating 3D histograms by taking in continuous x, y, z points and figuring out how to divide the data up into bins, and then counting the number of hits in each bin.
In the code, occupied is a 3D logical array indicating whether the pixel has non-zero value or not (and thus has to be drawn) . It uses the indices of those locations together with the calculated boundaries of each edge in order to put together patch face and patch vertex information to use to draw around the entire occupied voxel.
Your elem array corresponds to my occupied array. But because my code was designed for histograms, the input x, y, z coordinates are used to figure out the x, y, z coordinates for drawing purposes.
ac_bm_mat
ac_bm_mat 2022년 4월 29일
Will Nx = 8; Ny = 8; Nz = 8; in my case?
Also will it be occupied = elem >0 in my case?
ac_bm_mat
ac_bm_mat 2022년 4월 29일
One more doubt. If the value of occupied is 0.8 for some voxel, 0.9 for some voxel and 1 for some voxel and 0 for all others. How to plot these things?
Also can you please simplify your original code and remove additional lines not required for my case?
Walter Roberson
Walter Roberson 2022년 4월 29일
Sorry, I am too busy the next few days to simplify that code for your case.
ac_bm_mat
ac_bm_mat 2022년 4월 29일
It's okay. Whenever you are free, please try to simplify it. Thank you so much.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

릴리스

R2020b

질문:

2022년 4월 29일

댓글:

2022년 4월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by