How to get all workspace variables with their respective value from within a function?
17 views (last 30 days)
Show older comments
Say I have some variables
var1 = 3;
str2 = "MATLAB";
syms x y
eqn1 = x + y;
Say I want to get all the variables in this workspace with their respective values from within some function:
function listVars()
allVarNames = evalin( 'base', 'who' )
allVarValues = ???
t = table(allVarnames, allVarValues)
end
Is this possible? If not, is it possible if the variables are of the same type?
----------------------------------------------
I already tried ??? =
evalin('base','allVarNames')
%and
evalin('base',allVarNames)
But these result in these errors respectively:
Error using evalin
Unrecognized function or variable 'allVarNames'.
%and
Error using evalin
Must be a text scalar.
2 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!