performance - Speed up for loop in Matlab -


i have following for loop makes program runs slow when file size big. best way vectorize it.

i read data ply file here using command, data = textread(filename, '%s','delimiter', '\n');.data n*1 cell array. each element in data 7*1 cell array of char values. sample data file here.

for = 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 want

>> pc = str2double([data{:}].') pc =     0.1033   -0.2737    0.8570  221.0000  196.0000  174.0000  255.0000     0.1054   -0.2731    0.8550  220.0000  195.0000  173.0000  255.0000     ...     0.1139   -0.2803    0.8490  221.0000  194.0000  172.0000  255.0000     0.1117   -0.2829    0.8500  225.0000  200.0000  178.0000  255.0000 

you can remove last column , row (as appears done in question) with

>> pc = pc(1:end-1, 1:end-1) pc =     0.1033   -0.2737    0.8570  221.0000  196.0000  174.0000     0.1054   -0.2731    0.8550  220.0000  195.0000  173.0000     ...     0.1139   -0.2803    0.8490  221.0000  194.0000  172.0000 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -