Creating 'n' matrices with each one with 'n' in its name
1 view (last 30 days)
I am building 'n' matrices line by line:
YEAR1 = zeros(DATE_RANGE(1,3));
YEAR2 = zeros(DATE_RANGE(2,3));
YEAR3 = zeros(DATE_RANGE(3,3));
To avoid manually entering each line, I would like to use a looping method, e.g.,
YEARn = zeros(DATE_RANGE(n,3));
My searches bring me to the concept of 'dynamic access' (eval), which is not recommended. But am not sure if this applies to my case.
More Answers (1)
Walter Roberson on 17 Sep 2023
See https://www.mathworks.com/matlabcentral/answers/2020976-i-want-to-store-the-vector-from-each-for-loop-iteration-how-can-i-do-this#answer_1310391 for sample code that iterates through variable names, a, b, c, d, e, ... z, aa, ab, ac, ...