How to get all workspace variables with their respective value from within a function?
17 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!