I have the following for
loop which makes my program runs very slow when the file size is very big. What is the best way to vectorize it.
I read data
from a PLY file as here using the command, data = textread(fileName, '%s','delimiter', '\n');
.data
is a n*1 cell array. Each element in data
is a 7*1 cell array of char values. Sample data file is here.
for i = 1:length(data)-1
pc(i, 1) = (str2double(cellstr(data{i,1}{1,1})));
pc(i, 2) = (str2double(cellstr(data{i,1}{2,1})));
pc(i, 3) = (str2double(cellstr(data{i,1}{3,1})));
pc(i, 4) = (str2double(cellstr(data{i,1}{4,1})));
pc(i, 5) = (str2double(cellstr(data{i,1}{5,1})));
pc(i, 6) = (str2double(cellstr(data{i,1}{6,1})));
end
This will do what you want
You can remove the last column and row (as appears to be done in your question) with