I want to read a PLY file to a MATLAB matrix starting from the next line of the string end_header using the dlmread
function as suggested in this SOF question. Sample PLY file is given here. Currently the starting line is hardcoded as follows, but it is not suitable as the number of header rows in a PLY file may change.
data = dlmread(fileName, ' ', 14, 0);
There are a multitude off different ways you could do this. One option is to use
textscan
to read in the entire file and a mix ofstrfind
andfind
to determine the row that contains'end_header'
likethen you can use
dlmread
asor extract the numeric data based on my previous answer.
Another method, which may be better if your files contain a lot of data after
'end_header'
but not a lot before it would be to read each line until you find'end_header'
usingfgets
and then use
dlmread
or extract the numeric data based on my previous answer.