Point cloud with Matlab

3 views (last 30 days)
QS
QS on 20 Feb 2019
Commented: Walter Roberson on 28 Mar 2025
How to divide a point cloud in four quadrants? Please help me with the code in matlab.
  1 Comment
Walter Roberson
Walter Roberson on 28 Mar 2025
Use pca() to find the orientation of the planes, and use the centroid of the point cloud as the center of the planes

Sign in to comment.

Answers (1)

Dev
Dev on 28 Mar 2025
Hi @QS,
To divide a point cloud into four quadrants, we can loop through each point using a ‘for’ loop and assign it to a quadrant. I have added a reference code snippet below which can be used inside this loop to help us achieve the same-
% Assign each point to the respective quadrant
if x >= origin(1) && y >= origin(2)
quadrant1 = [quadrant1; x, y]; % Quadrant I
elseif x < origin(1) && y >= origin(2)
quadrant2 = [quadrant2; x, y]; % Quadrant II
elseif x < origin(1) && y < origin(2)
quadrant3 = [quadrant3; x, y]; % Quadrant III
else
quadrant4 = [quadrant4; x, y]; % Quadrant IV
end
To visualize the point cloud, we can use the ‘scatter’ function in MATLAB. I have attached an example output of a point cloud divided into quadrants below, for your reference.
For more information regarding the usage of the ‘for’ loop and the ‘scatter’ function, please refer to the documentation links below-
Hope this solves the query.

Community Treasure Hunt

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

Start Hunting!