MATLAB Answers

0

Base workspace variable name

Is there any command to get the base workspace variable name ?

  2 Comments

In which contest? within a function? Which variable? All of them? An input to a function?
I have a function like below
function data()
run('D:\......\comp.m')
end
so now comp.m will run and store the repective variable in base workspace.
Problem is now i need to get the name of the base workspace variables

Sign in to comment.

1 Answer

Answer by Thorsten
on 4 Dec 2015
Edited by Thorsten
on 4 Dec 2015
 Accepted Answer

S = whos;
varname = {S.name};

  5 Comments

Great . Thanks a lot. Now works fine.
"use evalin": Here be dragons. Do not go down that path unless you know what you're doing and know all the pitfalls of using eval and its friends.
For what reasons do you want to have the list of variables in the base workspace?
I have a function like below
function data()
run('D:\......\comp.m')
end
so now comp.m will run and store the repective variable in base workspace only right. I need the variable name so oly. Like wise this will run in loops

Sign in to comment.