MATLAB: How to make new variables and values in for loop

for loopnaming

I want to make and define variables with for loop like:
for i=1:3
something
Ai = …
something
end
so that after running this, I have defined variables of Ai, or A1, A2, A3 in this case
I tried to search and found out there is something such as A{i} or saving values to arrays, but in the end I need to transform them again as the above and get separate defined variables…
Thank you.

Best Answer

Please do not create numbered variables!
If you want varying values for different iterations, subscript ‘A’ instead:
A(i) = ...
or:
A{i} = ...
depending upon what you want to do, and the size of ‘A’.
Related Question