[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Get names of variables in symbol table
From: |
John W. Eaton |
Subject: |
Get names of variables in symbol table |
Date: |
Sat, 22 Feb 2003 17:09:04 -0600 |
On 22-Feb-2003, Andy Adler <address@hidden> wrote:
| Is there a way to get the names of all the current variables,
| or, alternatively, all the variables in a *.mat file.
|
| I want to load a *.mat file and process each variable.
| The best idea that I've currently though of is
|
| x=system(['echo "load datafile.mat; whos" | octave -qfH | ' ...
| 'sed -e"s/.*[0-9]\\+ \\+[0-9]\\+ \\+//"']);
|
| now x is a list of the variables in datafile.mat
|
| I hope theres an easier way?
I think so, at least with recent 2.1.x snapshots. If you use
x = load ("file.mat");
then x should be a struct with each element corresponding to a
variable in the file. Then you can use struct_elements to get the
list of names (which reminds me that we should probably have a
fieldnames function for Matlab compatibility...).
jwe
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------