Since you're happy to take other suggestions as well, I'm going to suggest you do this through a simple MATLAB script. MATLAB takes a while to start up, so it is quite inefficient to start MATLAB anew for each "condition".
I'm going to assume that your text file example is a simplification, maybe you have multiple parameters per line, and need to pass each of them as an argument to the conditions
function. For example the file conditions.txt
could contain:
'c01',5,false
'c02',100,true,0,'foo'
...
and you'd want to generate the calls
conditions('c01',5,false)
conditions('c02',100,true,0,'foo')
...
The following code accomplishes this:
f = fopen('conditions.txt','rt');
while true
data = fgetl(f);
if isequal(data,-1), break, end
eval('conditions(',data,')')
end
fclose(f);
exit
You could save that as an M-file script (e.g. runconditions.m
), and execute it from bash as follows:
matlab -nosplash -nodesktop -r runconditions
eval
is evil, in general, but in this case it's the same as what you'd be doing from the Bash script in Christian's answer. The only difference with that answer is that you avoid starting up MATLAB repeatedly.