What orders to save a file by string AND variable? MATLAB -
i have loop goes through 7 elements in array , operation, , gets 'work' (name of variable) variable. want save work variable in form of 'work_#ofexperiment' (experiments 1 through 7)
so have experiment 1, 2, 3, 4, 5, 6, 7
and array [stuff1,stuff2,stuff3,stuff4,stuff5,stuff6,stuff7];
for i=1:7
do stuff work = save work based on order of , name work_experiment#
save('work_%s',work,experiment(i)) not working
you need pass names of variables strings save function.
save(sprintf('work_%d',i), 'work', 'experiment')
with save function cannot partial saving experiment(i). once saved can partially update mat file using matfile function. (http://www.mathworks.com/help/matlab/ref/matlab.io.matfile-class.html).
matobj = matfile('work_%s') matobj.properties.writable = true matobj.experiment(i) = newvalue;
Comments
Post a Comment