I had a text-based file with .ptx suffix. It contains the point cloud information please see the following example

100
50
0.352 -5.207 -0.823 0.238 61 61 61
0.345 -5.202 -0.824 0.234 60 60 60
...

Question:

How can I load the file from the third row (ignore the first two rows) and save is as a matrix.

有帮助吗?

解决方案

I would recommend using textscan.

Something like:

in = textscan('sample.ptx','%f %f %f %f %f %f %f','HeaderLines',2)

You can specify a number of header lines to skip using 'HeaderLines'. The %f refers to the format of the input data. Hope that helps.

其他提示

Here is a full example of how to apply textscan and transform the result in to a matrix:

fid = fopen('textscantest.txt','r');
assert(fid~=1); % verify file is opened
C = textscan(fid,'%f %f %f %f %f %f %f','HeaderLines',2);
fclose(fid);
M = [C{:}]

Note that since you want it all in the same matrix, you need the same data type and all %f is required for each column.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top