MATLAB: How to assign a name to a Table given set of names

table properties

Hi folks. I have a long code which runs every time with the number of items a set. For instance I have a set: Subjects = {Name1,Name2,Name3}. My FOR produces 3 different tables/matrixes: A, B and C. So each time the FOR statement runs, it overwrites the tables generated for each different subject. Is there a way to insert a code inside my FOR statement to store each table/matrix (A,B,C) and name each after the subject? For instance, something like this:
Subjects = {'Name1','Name2','Name3'}
for i=1:length(Subjects)
A = magic(2)
B = magic(3)
C = magic(4)
strcat('A_',Subjects(1)) = A % These were my best attempts, But It doesn't work.
strcat('B_',Subjects(2)) = B
strcat('C_',Subjects(3)) = C
end
% Any help much appreciated.

Best Answer

Hi Edson,
would that work for you?
assignin('base', ['A_' Subjects{1}], A);