When doing a class project, I needed to export from Matlab a bunch of 3D points (with color) to PLY files, so as to visualize the point cloud using MeshLab. With the instruction from Konstantine Tsotsos, the process is as simple as:

Followed by the data as rows of x y z r g b: