MATLAB: Loading variable from whos

variables whos loading

Hi I am working on a group of variables, and I want work on every of them changing them value in loop.
I grouped interested me variables by whos('I2*')
Thank You.

Best Answer

Avoid such meta-programming. Guessing the names of the variables and construct some obscure EVAL command to access them increases the complexity of your program without any benefit.
If the variables belong together, define them as fields of a struct. Then dynamic field names allow a fast and save processing:
a.x = 1:10;
a.y = rand(10);
fields = fieldnames(a);
for k = 1:length(fields)
disp(a.(fields{k}));
end