Try this
[a b c d] = deal(1,2,3,4);
data = strcat(importdata('input.csv', sprintf('\n')), ';');
Matrix = eval(['[' data{:} '[]]']);
EDIT: To avoid slowdown by eval
you can write the string in another m-file and call it instead in the loop. Something like this:
[a b c d] = deal(1,2,3,4);
matDef = regexprep(fileread('input.csv'), {'(\r\n|\r|\n)' ';^'}, {';' ''});
f = fopen('inputMatrix.m', 'w');
fwrite(f, ['Matrix = [' matDef '];'])
fclose(f);
rehash
for k=1:100000,
inputMatrix
end
You need the rehash
to ask matlab to add newly-created inputMatrix
to list of known functions.