How to generate a point cloud in 3D?

Leo Müller · Feb 19, 2022 · 1.9K views
Question
Hello dear community,   I would like to know if there is a fast way to create a cloud in 3D which consists of points. I would like to get something like this:   The points should be written into a simple matrix. Each row should represent one point. Thank you for your help!  
Expert Answer
Profile picture of Prashant Kumar
Prashant Kumar PhD Expert
Answered Sep 12, 2026
This might be a good starting point:
 
 
[x,y,z] = ndgrid(1:5:100,1:5:100,1:5:100);
scatter3(x(:),y(:),z(:),'.')

 

point cloud in 3D

The ndgrid function will return multiple arrays of the same shape with one of its inputs replicated along one dimension of each of its outputs.
 
The syntax x(:) says to convert that 3D array into a vector.
 
The scatter3 function takes 3 vectors and plots a marker at the location defined by each row of the three.
 
The '.' argument to scatter3 tells it to draw a dot, rather than one of the bigger and more complex markers.
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!