I want to make a script that saves multiple base variables from the "base name". My attempt looks like this :
function [outargs] = save_with_basename(b)
basePath = 'C:\path\';
Var1 = evalin('base', [b '_1']);
Var2 = evalin('base', [b '_2']); % .. etc
for i=1:N
save([basePath b '_' int2str(i) '.mat'], ['Var' int2str(i)]);
end
end
This saves the files but the variable saved in the file is called Var1 (see the pic.), but I want it to be called 'Foo_1' if the function was called with :
save_with_basename('Foo');
I think the second argument to save works with the function variable, so it looks like I have to change its name dynamically (which is probably not possible?) , so I wonder if there is a way I can do it.
Thanks for any help !
