MATLAB: List values of variables with wildcard

variablewildcard

Is there a command or other simple way to list the values of variables specified by a wildcard? For example, if I type
>> command a*
MATLAB would give me the names and values of all variables that start with "a". (who and whos do not give the values.) Thanks. Greg Reese

Best Answer

What you're trying to do sounds iffy. You should not be manipulating data by their variable names. Saying that, it's very easy but it involves eval which should raise some alarm bells:
varnames = who('a*');
values = cellfun(@eval, varnames, 'UniformOutput', false);
cell2table([varnames, values], 'VariableNames', {'Variable', 'Value'})