Possible Duplicates: How to concatenate a number to a variable name in MATLAB? MATLAB: How can I use a variables value in another variables name?
I have the following code:
x = textread('/home/data/data.txt','%s')
for i=1:50
S=load(['/home/data/',x{i},'_file.mat'])
info_',x{i},' = strcat(S.info1, S.info2)
end
Of course, the last line (info_',x{i},' = strcat(S.info1, S.info2)
) doesn't work. It just doesn't seem to be possible to use a variable to create MATLAB elements. Is this right or am I just doing something wrong here? Is there an elegant workaround?