`clear variable` does not work ?

Sergei Steshenko sergstesh at yahoo.com
Thu Jan 31 04:07:10 CST 2008


--- Matthias Brennwald <matthias.brennwald at nagra.ch> wrote:

> 
> On Wed, 2008-01-30 at 14:46 -0600, help-octave-request at octave.org wrote:
> > Message: 9
> > Date: Wed, 30 Jan 2008 12:10:46 -0800
> > From: Maynard Wright <m-wright at eskimo.com>
> > Subject: Re: `clear variable` does not work ?
> > To: help-octave at octave.org
> > Message-ID: <200801301210.46973.m-wright at eskimo.com>
> > Content-Type: text/plain;  charset="iso-8859-1"
> > 
> > I executed the following script using Octave 2.1.72:
> > 
> > global x = [1 2 3];
> > clear x;
> > global x = [9 9 9];
> > x(3) = 7;
> > printf(" x = %d\n", x);
> > 
> > The result was:
> > 
> > x = 1
> > x = 2
> > x = 7
> > 
> > It seems to me that I can't delete or modify, as a whole, the global
> > variable 
> > x, but I can write over individual elements.
> > 
> > Maynard
> 
> I can't offer a solution to your problem, but I can add a bit to the
> confusion. Consider this (with Octave 3.0 on Ubuntu Linux 7.10):
> 
> octave:1> global x = [1 2 3]
> octave:2> clear x
> octave:3> x
> error: `x' undefined near line 33 column 1
> 
> So, it looks like x has been cleared and does not exist anymore. But, if
> I continue with the following, this seems not to be the case:
> 
> octave:4> global x = [9 9 9]
> octave:5> x
> x =
> 
>    1   2   7
> 
> There are two things that confuse me:
> 1. Why is x not equal to [9 9 9]?
> 2. Why does Octave remember the previous value of x, although it has
> been cleared previously?
> 
> I don't believe this is a bug, because it is so fundamental. I guess
> this has something to do with me (and others) not understanding well how
> things work. Can someone enlighten me?
> 
> Matthias
> 
> _______________________________________________
> Help-octave mailing list
> Help-octave at octave.org
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
> 


Adding even more to everybody's confusion:

"
octave:1> global x = [1 2 3]
octave:2> x
x =

   1   2   3

octave:3> clear x
octave:4> x
error: `x' undefined near line 4 column 1
octave:4> global x = [9 9 9]
octave:5> x
x =

   1   2   3

octave:6> x = [9 9 9]
x =

   9   9   9

octave:7>    
".

I.e. giving 'x' value not redeclaring it as global does produce the expected value.

Regards,
  Sergei.

Applications From Scratch: http://appsfromscratch.berlios.de/


      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 



More information about the Help-octave mailing list