3.0

3.0 | 2 ratings Rate this file 31 downloads (last 30 days) File Size: 1.32 KB File ID: #23551

Equally spaced structured Point Cloud Cuboid generation

by Jveer

 

04 Apr 2009

Code covered by BSD License  

Simple function to generate equally spaced point cloud forming a cuboid

Download Now | Watch this File

File Information
Description

Inputs are vectors giving the x, y and z range. e.g x=1:100;y=40:70;z=80:250;

Apologies for lack of description but this submission is for a specific request. It is an extract from a much larger program.

% - B.I SOLID POINT CLOUD CUBOID
function [P]=Cuboid(x,y,z)
% - Generates coordinates for a solid cuboid composed of points

a=length(x);b=length(y);c=length(z); % assigning for coding simplicity
% B.I.1. Finding all x coordinates
xp=zeros(1,a*b*c); % preallocating
for nx=1:a
    if nx==1,xp(1:c*b)=(repmat(x(nx),1,c*b));
    else xp(((nx-1)*c*b)+1:nx*c*b)=repmat(x(nx),1,c*b);end
end
% B.I.2. Finding all y coordinates
yp=zeros(1,b*c); % preallocating
for ny=1:b
    if ny==1,yp(1:c)=repmat(y(ny),1,c);
    else yp(((ny-1)*c)+1:ny*c)=repmat(y(ny),1,c);
    end
end
yp=repmat(yp,1,a);
% B.I.3. Finding all z coordinates
zp=repmat(z,1,b*a);
% B.I.4. Coordinates of the cuboid generated.
P=[xp;yp;zp];
end % To Optimize

Required Products Communications Blockset
MATLAB release MATLAB 7.4 (R2007a)
Zip File Content  
Other Files Cuboid.m,
license.txt
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
07 Apr 2009 Jveer

Communications blockset not required! i don't remember putting that there!

if anyone manages to speed up this function, please let me know.

08 Apr 2009 PXlab

No! Regards

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
point cloud Jveer 06 Apr 2009 10:08:42
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com