Strange?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Strange?

Dr.-Ing. Dieter Jurzitza
Dear listmembers,
I am currently trying to go through the documentation - it's something like 1000 pages, so this takes time :-). I am using octave 5.2.0. When I say

>> A=5;
>> A
A =  5
>> isvarname (A)
ans  =  0

shouldn't this be "1" rather than "0"? The manual states "Return true if name is a valid variable name". In my example I consider "A" a valid variable name, isn't it? So, could you shed some light on what I am doing wrong here?
Thank you,
take care

Dieter




Reply | Threaded
Open this post in threaded view
|

Re: Strange?

Ian McCallion
On Tue, 10 Mar 2020 at 08:22, [hidden email]
<[hidden email]> wrote:

>
> Dear listmembers,
> I am currently trying to go through the documentation - it's something like 1000 pages, so this takes time :-). I am using octave 5.2.0. When I say
>
> >> A=5;
> >> A
> A =  5
> >> isvarname (A)
> ans  =  0
>
> shouldn't this be "1" rather than "0"? The manual states "Return true if name is a valid variable name". In my example I consider "A" a valid variable name, isn't it? So, could you shed some light on what I am doing wrong here?

you need to say:

   isvarname('a')

Cheers... Ian


Reply | Threaded
Open this post in threaded view
|

Re: Strange?

Octave - General mailing list

On 10/03/2020 10:47, Ian McCallion wrote:

> On Tue, 10 Mar 2020 at 08:22, [hidden email]
> <[hidden email]> wrote:
>> Dear listmembers,
>> I am currently trying to go through the documentation - it's something like 1000 pages, so this takes time :-). I am using octave 5.2.0. When I say
>>
>>>> A=5;
>>>> A
>> A =  5
>>>> isvarname (A)
>> ans  =  0
>>
>> shouldn't this be "1" rather than "0"? The manual states "Return true if name is a valid variable name". In my example I consider "A" a valid variable name, isn't it? So, could you shed some light on what I am doing wrong here?
> you need to say:
>
>     isvarname('a')
>
> Cheers... Ian
>
>
Most likely  isvarname('A') - IIRC Octave is case-sensitive.

--Sergei.



Reply | Threaded
Open this post in threaded view
|

AW: Strange?

Dr.-Ing. Dieter Jurzitza
Hello,
first of all: many thanks to all commenters - and you were fully right (and I was fully wrong :-))

A="B";
isvarname (A)
ans = 1

because the value of "A" (which is "B" in this case) is a valid variable name. So, A=1; isvarname(A) returns isvarname(1) and therefore 0 because "1" cannot be the name of a variable.

So, I understood it now :-). One thing that I had misunderstood was that I had had thought isvarname would check if "A" is actually the name of a variable. However, I understand now this is only a test whether or not it is basically possible to use it as the name of a variable.

Take care, thank you for a great program


Dieter




-----Original-Nachricht-----
Betreff: Re: Strange?
Datum: 2020-03-10T12:58:33+0100
Von: "Sergei Steshenko via Help-octave" <[hidden email]>
An: "[hidden email]" <[hidden email]>


On 10/03/2020 10:47, Ian McCallion wrote:

> On Tue, 10 Mar 2020 at 08:22, [hidden email]
> <[hidden email]> wrote:
>> Dear listmembers,
>> I am currently trying to go through the documentation - it's something like 1000 pages, so this takes time :-). I am using octave 5.2.0. When I say
>>
>>>> A=5;
>>>> A
>> A =  5
>>>> isvarname (A)
>> ans  =  0
>>
>> shouldn't this be "1" rather than "0"? The manual states "Return true if name is a valid variable name". In my example I consider "A" a valid variable name, isn't it? So, could you shed some light on what I am doing wrong here?
> you need to say:
>
>     isvarname('a')
>
> Cheers... Ian
>
>
Most likely  isvarname('A') - IIRC Octave is case-sensitive.

--Sergei.






Reply | Threaded
Open this post in threaded view
|

RE: Strange?

Tony Richardson
It sounds as if you want to use exist("A") instead of isvarname("A").

Tony

> -----Original Message-----
> From: Help-octave <help-octave-
> bounces+richardson=[hidden email]> On Behalf Of
> [hidden email]
> Sent: Tuesday, March 10, 2020 7:22 AM
> To: [hidden email]
> Subject: AW: Strange?
>
> Hello,
> first of all: many thanks to all commenters - and you were fully right (and I
> was fully wrong :-))
>
> A="B";
> isvarname (A)
> ans = 1
>
> because the value of "A" (which is "B" in this case) is a valid variable name.
> So, A=1; isvarname(A) returns isvarname(1) and therefore 0 because "1"
> cannot be the name of a variable.
>
> So, I understood it now :-). One thing that I had misunderstood was that I
> had had thought isvarname would check if "A" is actually the name of a
> variable. However, I understand now this is only a test whether or not it is
> basically possible to use it as the name of a variable.
>
> Take care, thank you for a great program
>
>
> Dieter
>
>
>
>
> -----Original-Nachricht-----
> Betreff: Re: Strange?
> Datum: 2020-03-10T12:58:33+0100
> Von: "Sergei Steshenko via Help-octave" <[hidden email]>
> An: "[hidden email]" <[hidden email]>
>
>
> On 10/03/2020 10:47, Ian McCallion wrote:
> > On Tue, 10 Mar 2020 at 08:22, [hidden email]
> > <[hidden email]> wrote:
> >> Dear listmembers,
> >> I am currently trying to go through the documentation - it's
> >> something like 1000 pages, so this takes time :-). I am using octave
> >> 5.2.0. When I say
> >>
> >>>> A=5;
> >>>> A
> >> A =  5
> >>>> isvarname (A)
> >> ans  =  0
> >>
> >> shouldn't this be "1" rather than "0"? The manual states "Return true if
> name is a valid variable name". In my example I consider "A" a valid variable
> name, isn't it? So, could you shed some light on what I am doing wrong here?
> > you need to say:
> >
> >     isvarname('a')
> >
> > Cheers... Ian
> >
> >
> Most likely  isvarname('A') - IIRC Octave is case-sensitive.
>
> --Sergei.
>
>
>
> 
>