MATLAB: How to change the name of variables using a loop

concatenateiterationnames

I need to do the same matrix calculations repeatedly, but I want to rename the variable within the loop. e.g. I need matrices R_1 R_2 R_3 R_4. I want to be able to set matrix R_1=( calcs for ii=1); R_2=( calcs for ii=2), etc. I know I can convert ii to a string using num2str(ii), but how do I concatenate that to R? R_ii=(calcs for ii)?
Am I going to need some sort of cell array to do that? I'm trying to avoid cells.

Best Answer

In MATLAB it is (almost always) better to not create variable names on the fly:
Use a cell or struct instead.
I know you were looking for a tidy solution... this is the tidy solution.