I am trying to save variables in a for loop. The following new variable can be created:
eval(['C' num2str(j) '=B']);
But I get an error while using this to save the variable by the following command :
save([dataDir, files(j).name],eval(['C' num2str(j) '=B']),'-append')
The error is : (Error: The expression to the left of the equals sign is not a valid target for an assignment.).
I wonder what is wrong with my approach and how can I save the changing variable name in changing file name in a for loop.
I will greatly appreciate your assistance.