[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `clear variable` does not work ?
From: |
Matthias Brennwald |
Subject: |
Re: `clear variable` does not work ? |
Date: |
Thu, 31 Jan 2008 08:15:54 +0100 |
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