help-octave
[Top][All Lists]
Advanced

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

Re: Strcmp not behaving as expected


From: Ben Abbott
Subject: Re: Strcmp not behaving as expected
Date: Mon, 22 Oct 2012 18:37:35 -0400

On Oct 22, 2012, at 6:05 PM, Jordi Gutiérrez Hermoso wrote:

> On 22 October 2012 17:59, Martin Helm <address@hidden> wrote:
>> Am 22.10.2012 23:46, schrieb Jordi Gutiérrez Hermoso:
>>> On 22 October 2012 17:44, Mumble07 <address@hidden> wrote:
>>>> Huh.  I just went back and tried strcmp in the command line again, and the
>>>> problem appears to have dissapeared.  Since then, I've restarted octave, as
>>>> well as the terminal instance.  Could it have been something wonky in the
>>>> terminal? I could have sworn I restarted octave several times.
>>> You probably defined strcmp to be something else. Did you mess up your
>>> load path? Was strcmp a variable name?
>>> 
>> Good catch: Sounds like a possible reason, if I do that then I get such
>> an error
>> 
>> octave:1> strcmp=1
>> strcmp =  1
>> octave:2> strcmp ('g_90', 'vent') error: A(I,J): row index out of
>> bounds; value 103 out of bound 1
>> octave:2>
>> 
>> which is a logical consequence.
> 
> It appears that citizen Mumble07 defined strcmp to be some
> 114-by-at-least-118 matrix of zeros and ones and then tried to index
> it with strings.
> 
> Perhaps there should be some warning about attempting to index
> matrices with strings. What does Matlab do if you attempt to do this?

strcmp = round (rand (114,118));
strcmp ('g_90', 'vent')

ans =

     0     1     0     0
     1     0     1     0
     0     0     1     1
     1     0     1     0

Ben



reply via email to

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