Main Content


Write 3-D point cloud to PLY or PCD file



pcwrite(ptCloud,filename) writes the point cloud object, ptCloud, to the PLY or PCD file specified by the input filename.

pcwrite(ptCloud,filename,Encoding=encodingType) writes a pointCloud object, ptCloud, to a PLY file that is in the specified format.


collapse all

ptCloud = pcread("teapot.ply");

pc = pcread('object3d.pcd');

Input Arguments

collapse all

File name, specified as a character vector or string scalar. The input file type must be a PLY or PCD format file.

For a PLY-file, the pcwrite function converts an organized M-by-N-by-3 point cloud to an unorganized M-by-3 format. It converts the format because PLY files do not support organized point clouds. To preserve the organized format, you can save the point cloud as a PCD-file.

If you do not specify the file name with an extension, the function writes the file in a PLY-format. All NaN or Inf values will be skipped when writing to a PLY file.

Object for storing point cloud, specified as a pointCloud object.

PLY or PCD formatted file, specified as "ascii", "binary", or "compressed" for the file format.

File FormatValid Encodings

"ascii", "binary"


"ascii", "binary", or "compressed"


The PCD file format does not support storing colors of datatype uint16. You can downsize the color to uint8 to save the file in a PCD format or save it in the PLY format.

To improve performance when writing large point clouds, use the "compressed" or "binary" file type.

Version History

Introduced in R2015a