[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `clear variable` does not work ?
From: |
Sergei Steshenko |
Subject: |
Re: `clear variable` does not work ? |
Date: |
Thu, 31 Jan 2008 02:07:10 -0800 (PST) |
--- Matthias Brennwald <address@hidden> wrote:
>
> On Wed, 2008-01-30 at 14:46 -0600, address@hidden wrote:
> > Message: 9
> > Date: Wed, 30 Jan 2008 12:10:46 -0800
> > From: Maynard Wright <address@hidden>
> > Subject: Re: `clear variable` does not work ?
> > To: address@hidden
> > Message-ID: <address@hidden>
> > 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
> address@hidden
> 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