Thread Subject: Reading a list of workspace variables

Subject: Reading a list of workspace variables

From: Marco D'Angelo

Date: 26 Jun, 2007 12:29:39

Message: 1 of 4

Hi everyone.

I've got to read data from a list of matrices archived in the
workspace (obtained by loading ascii files) called
'Node001','Node002' and so on...

I've tried to make up, in a for-loop, a string with strcat and
num2str(i) but, then, I am returned only a string with the noame of
the variable whose content I can't access.

The solution should be simple...

But I am not finding it...

Thx everyone, as usual.

Bye,

M.D.

Subject: Reading a list of workspace variables

From: per isakson

Date: 26 Jun, 2007 12:59:43

Message: 2 of 4

Marco D'Angelo wrote:
>
>
> Hi everyone.
>
> I've got to read data from a list of matrices archived in the
> workspace (obtained by loading ascii files) called
> 'Node001','Node002' and so on...
>
> I've tried to make up, in a for-loop, a string with strcat and
> num2str(i) but, then, I am returned only a string with the noame of
> the variable whose content I can't access.
>
> The solution should be simple...
>
> But I am not finding it...
>
> Thx everyone, as usual.
>
> Bye,
>
> M.D.

This code hints to another solution

v1 = 1;
v2 = 2;
list = who( 'v*' );
for name = list', s.(char(name)) = eval( char( name ) ); end
>>s
s =
      v1: 1
      v2: 2

However, I doubt I understand your question

/ per

Subject: Reading a list of workspace variables

From: Peter Boettcher

Date: 26 Jun, 2007 13:45:10

Message: 3 of 4

"Marco D'Angelo" <marco.d15@libero.it> writes:

> Hi everyone.
>
> I've got to read data from a list of matrices archived in the
> workspace (obtained by loading ascii files) called
> 'Node001','Node002' and so on...
>
> I've tried to make up, in a for-loop, a string with strcat and
> num2str(i) but, then, I am returned only a string with the noame of
> the variable whose content I can't access.

Don't load them that way. Instead, use an output argument to load,
plus cell arrays to store the data in:

data{1} = load('Node001');
etc.

Now you can loop through data{1}, data{2}, etc, and your workspace
won't be clogged.



-Peter

Subject: Reading a list of workspace variables

From: Marco D Angelo

Date: 26 Jun, 2007 16:01:31

Message: 4 of 4

Peter Boettcher wrote:
>
>
> "Marco D'Angelo" <marco.d15@libero.it> writes:
>
>> Hi everyone.
>>
>> I've got to read data from a list of matrices archived in the
>> workspace (obtained by loading ascii files) called
>> 'Node001','Node002' and so on...
>>
>> I've tried to make up, in a for-loop, a string with strcat and
>> num2str(i) but, then, I am returned only a string with the
noame
> of
>> the variable whose content I can't access.
>
> Don't load them that way. Instead, use an output argument to load,
> plus cell arrays to store the data in:
>
> data{1} = load('Node001');
> etc.
>
> Now you can loop through data{1}, data{2}, etc, and your workspace
> won't be clogged.
>
>
>
> -Peter
>
  OK, I'll try that way.

Thanks a lot,

Marco

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com