MATLAB: Adding arrays found using ‘who’ function

adding arrayswho

Hello,
I have used the 'who' function to obtain the required 2D numeric arrays from a list of variables, like this;
Find_Target_Vars = who ('Target_Str')
Find_Target_Vars =
'A'
'B'
'C'
I now need to create a new (numeric,double) variable D, so that D = A + B + C.
How can I get from the list of variables in the cell array, Find_Target_Vars, to adding the actual listed variables together?
Many thanks, Iain

Best Answer

This is one of the (rare) cases EVAL comes in handy.
evalStr = sprintf('%s+', Find_Target_Vars{:}) ;
evalStr = evalStr(1:end-1) ; % remove trailing +
D = eval(evalStr)
Jos