I am using Matlab R2013a and I am trying to use the 'who' function within a function to retrieve a list of variables that begin with a name.
Let's say I have a list of variable in my workspace as follows:
- a = 1
- a_2 = 2
- a_3 = 3
when I run this:
who('a*');
it works fine.
But when I run the same thing inside a function like this:
function someFunction()
who('a*');
end
or
function someFunction()
disp(who('a*'));
end
It doesn't. No error, just no output.
If I had saved those variables in a Matlab file called
myVariables.mat
and run this within the same function like so:
function someFunction()
who('a*','myVariables');
end
It still doesn't work.
I can understand why the first might not work because of scope, but specifying the file to run the 'who' function on should work... what am I missing?
Any help would be appreciated.
Regards
Diaa
doc whoat least once thoroughly if you haven't before. I could see the solution right there. - Divakardisp(who('brain10*','Results_v2'));sould have been like this:disp(who('brain10*','-file','Results_v2'));. it works fine now, thanks for that. You learn something new everyday/night. - Lemming_87