How to access workspace variables one by one using m-script
古いコメントを表示
Hello,
I would like to read all workspace variables into array and check whether the name of variable is Matlab keyword or not. For example, I have four variables in workspace(a = 1;b=2;c=3;d=4;). I want to check if the varaible is keyword or not using matlab inbuilt function(iskeyword()) like below.
iskeyword('a')
ans =
0
>> iskeyword('if')
ans =
1
Is it possible check all base work space variables like this?
採用された回答
その他の回答 (1 件)
Azzi Abdelmalek
2015 年 6 月 1 日
a = 1;
b=2;
c=3;
d=4;
s1=whos
out=cellfun(@iskeyword,{s1.name})
4 件のコメント
N/A
2015 年 6 月 1 日
Azzi Abdelmalek
2015 年 6 月 1 日
in your example, the name of your variable is 'y', not 'if'
N/A
2015 年 6 月 1 日
Azzi Abdelmalek
2015 年 6 月 1 日
Maybe you need this
s1=whos
s2={s1.name}
for k=1:numel(s1)
out(k)=iskeyword(eval(s2{k}))
end
カテゴリ
ヘルプ センター および File Exchange で Variables についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!