Plot 3D cylindrical voxels filled or empty (boolean)

8 ビュー (過去 30 日間)
Diego Mesa
Diego Mesa 2020 年 5 月 23 日
コメント済み: darova 2020 年 5 月 25 日
Hi,
I have a matrix called h of size 9x36x20 [r, theta, z], containing 1's and 0's. Each number represent a voxel in a cylindrical figure. I would like to be able to plot in a 3d figure those with a 1 with some filled color, while leaving those with a zero transparent (could be with borders though, to make them look like a grid).
I would like to obtain something like this (drawn in inkscape, the matlab figure would be the whole cylinder with some red voxels).
Is it possible? I have already plotted some horizontal slices using patch to show the data at different heights, but this way is more representative
  1 件のコメント
darova
darova 2020 年 5 月 23 日
Can you attach the data? What about isosurface?

サインインしてコメントする。

採用された回答

darova
darova 2020 年 5 月 24 日
I draw your data
clc,clear
cla
load example.mat
[m,n,k] = size(diff);
[r,t,z] = ndgrid(1:m,1:n,1:k);
[x,y] = pol2cart(t,r);
ix = logical(diff);
plot3(x(ix),y(ix),z(ix),'.r')
axis vis3d
Here is the result. It's hard to see anything. Can you explain more?
  6 件のコメント
Diego Mesa
Diego Mesa 2020 年 5 月 25 日
Wow! Thank you very much!
darova
darova 2020 年 5 月 25 日
Easy way to add walls
t = (-15:15)*pi/180; % angle
t = [t(1) t t(end)];
[x1,y1] = pol2cart(t,1); % small arc
[x2,y2] = pol2cart(t,2); % large arc
x2([1 end]) = x1([1 end]);
y2([1 end]) = y1([1 end]);

サインインしてコメントする。

その他の回答 (1 件)

Diego Mesa
Diego Mesa 2020 年 5 月 24 日
編集済み: Diego Mesa 2020 年 5 月 24 日
Here I'm attaching some example data.
Also I'm showing a slice, so it's easier to understand what I need. Instead of presenting 20 horizontal slices (as z has 20 values), I need to build a 3D plot, showing all the voxels.
Thanks!

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by