Issue
I want to import a CSV file with mixed data types of numbers and variables/symbols. The import part was already discussed in Import CSV file with mixed data types.
Description
The CSV file here contains only 2x2 formulas (but in general 64x64 and I evaluate it 1'000'000 times). The problem that I was facing is the evaluation of the cells. This can not be done in the same way.
The matlab code is something like
% Parameter initialization
vector1 = ones(1e6);
a=1;
b=2;
c=3;
d=4;
% Formula calculation
vector2(1)=import('input000001.csv');
where my minimal input file input000001.csv
contains some formula, as e.g.:
a*vector1(1),2*vector1(1)/b
c+vector1(1),3*vector1(1)^d
Try this
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:You need the
rehash
to ask matlab to add newly-createdinputMatrix
to list of known functions.After some hints I achieved to come around with the following solution.
where
read_mixed_csv('input.csv',',')
is from Import CSV file with mixed data types.I am open for better answers!