Surface between two point clouds.

1 回表示 (過去 30 日間)
Núria Mercadé Besora
Núria Mercadé Besora 2022 年 5 月 3 日
回答済み: Dinesh 2023 年 9 月 20 日
Hi everybody!
I have a 3D matrix (NxNxM) describing a space in which there are three integer values to distinguix three diferent volumes in the space (0,1 and 2). I want two extract the indexes of neighbouring points with values 1 and 2, so I can later adjust a plane separating this two regions.
Any help regarding the extraction of the desired indexes is appreciated, thank you!

回答 (1 件)

Dinesh
Dinesh 2023 年 9 月 20 日
Hi Núria,
I understand that you are trying to extract indices from a 3D matrix.
Assuming your 3D matrix is of values 0, 1, 2 that represent three different volumes in the space. We can extract the linear indices of the values using the 'find' function in MATLAB. 'find' function returns returns a vector containing the linear indices of each nonzero element in array X.
Further you can convert the linear indices to subscripts using the 'ind2sub' function in MATLAB.
Please go through this example for more details
% creating a 3D array
A = [0,2;1,0];
B = [2,0;1,0];
C = [2,1;0,0];
Z = cat(3,A,B,C)
Z =
Z(:,:,1) = 0 2 1 0 Z(:,:,2) = 2 0 1 0 Z(:,:,3) = 2 1 0 0
% find returns indices of all non zero indices.
linear_indices_1 = find(Z==1)
linear_indices_1 = 3×1
2 6 11
% caluculation the row , column and depth of linear index 2
[row, col, dimension] = ind2sub(size(Z), 2)
row = 2
col = 1
dimension = 1
Please refer to the following MATLAB documentation for more details on 'find' and 'ind2sub' functions
  1. https://www.mathworks.com/help/matlab/ref/find.html
  2. https://www.mathworks.com/help/matlab/ref/ind2sub.html#d126e815337
Hope this helps.
Best regards,
Dinesh Reddy Gatla.

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by