help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loop variables


From: CdeMills
Subject: Re: Loop variables
Date: Thu, 19 Apr 2012 06:52:16 -0700 (PDT)

Jordi Gutiérrez Hermoso-2 wrote
> 
> On 18 April 2012 12:31, CdeMills <Pascal.Dupuis@> wrote:
>> Is there some way to detect automatically created variables ?
> 
> I'm not sure what you mean. There is only one way to create variables
> in Octave: to assign a value to them. I think the only solution would
> be to do something like creating new syntax for declaring variables,
> and this doesn't exist.
> 
>> Is it f.i. possible to disable this feature temporary, or just in a
>> script, in order to find every variables which should be reset at
>> each iteration ?
> 
> Why don't you wrap some of those loops into functions? In a function
> you will have local scopes.
> 
> 

I was not clear enough. A variable can be assigned using two syntax:
- global: a = randn(10, 10). In this case, whichever previously stored in a
is thrown away.
- partial: a(indx, 1) = 3. In this case, every component not referenced by
indx is kept from previous iteration, and that's the issue which plagued my
script.

The requested feature was thus to detect partial access to non-existing
variables. Now wrapping the whole loop body into a function indeed ensures a
fresh start at each iteration.

Regards

Pascal 


--
View this message in context: 
http://octave.1599824.n4.nabble.com/Loop-variables-tp4568235p4570970.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]