MATLAB: How to access workspace variables one by one using m-script

MATLABparametersvariablesworkspace

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?

Best Answer

You can get all the workspace variables like this:
>> varList = evalin('base', 'who');
Then check individual parameters:
>> iskeyword(varList{k}) % for k-th parameter