필터 지우기
필터 지우기

Slices through 3-D Volumes, formed by 1D-arrays

조회 수: 3 (최근 30일)
Andrew Sol
Andrew Sol 2023년 1월 12일
편집: Andrew Sol 2023년 1월 12일
f=
I have a set of 1D - arrays and values of the inequality f.
I need to build a series of slices for any of the planes of this volume. I don't know how to do this in Matlab, because the data is in vector form. Please help.
  댓글 수: 2
KSSV
KSSV 2023년 1월 12일
Your data lies in a sphere. You can make circular planes of required radius and center.
Andrew Sol
Andrew Sol 2023년 1월 12일
편집: Andrew Sol 2023년 1월 12일
@KSSV And if the volume is different from a regular form, from a sphere, for example, as in this case? How to build slices automatically?

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

채택된 답변

Walter Roberson
Walter Roberson 2023년 1월 12일
Nx = 50;
Ny = 51;
Nz = 52;
load f
load x
load y
load z
figure();
PointSize = 20;
scatter3(x, y, z, PointSize, f); colorbar();
minx = min(x); maxx = max(x);
miny = min(y); maxy = max(y);
minz = min(z); maxz = max(z);
xvec = linspace(minx, maxx, Nx);
yvec = linspace(miny, maxy, Ny);
zvec = linspace(minz, maxz, Nz);
[Xq, Yq, Zq] = meshgrid(xvec, yvec, zvec);
Fq = griddata(x, y, z, f, Xq, Yq, Zq);
Warning: Duplicate data points have been detected and removed - corresponding values have been averaged.
mask = Fq < 1/2 | Fq > 1;
Fq(mask) = nan;
figure();
sx = linspace(minx, maxx, 7);
sy = linspace(miny, maxy, 7);
sz = linspace(minz, maxz, 7);
H = slice(Xq, Yq, Zq, Fq, sx, sy, sz);
set(H, 'EdgeColor', 'none');
  댓글 수: 2
Joe
Joe 2023년 1월 12일
편집: Joe 2023년 1월 12일
非常に正確な計算.
Andrew Sol
Andrew Sol 2023년 1월 12일
편집: Andrew Sol 2023년 1월 12일
Thank you for your answer. The method is good, I tested it, but what does not suit me is that some contours are formed very sloppy and rough. I suggest this way:
[X,Y,Z] = ndgrid(0:0.1:2,0:0.1:2,0:0.1:2);
F = X.^2+Y.^2+Z.^2;
idx = double((F>=1/2) & (F<=1));
idx(idx==0) = NaN;
F1=Z.*idx;
X1=X.*idx;
Y1=Y.*idx;
Z1=Z.*idx;
P = [X1(:),Y1(:),Z1(:),F1(:)];
plot3(P(:,1),P(:,2),P(:,3),'o','MarkerSize', 3);
axis square
grid on
hold on
Here the grid is formed evenly. In addition, if we look at the location of the points on the slices, we can see that the points can be placed clearly in the desired slice.
[x y] = meshgrid(0:0.1:2,0:0.1:2); % Generate x and y for XY-plane
Z2=Z1; % auxiliary data
Z2(Z2~=0.5) = NaN; % Generate data for z-slice = 0.5, for example
plot3(P(:,1), P(:,2), Z2(:),'+','MarkerSize', 5) % Plot the slice
What else I would like: draw a border around each such "slice", remove the dots inside and, if possible, project all of slices (with differentc olors) onto one plane (well, so that all slices lie on the same surface). I haven't succeeded yet, but I'm working on it.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Point Cloud Processing에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by