[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strcmp with cell array does not work
From: |
Carnë Draug |
Subject: |
Re: strcmp with cell array does not work |
Date: |
Thu, 27 Dec 2012 18:58:59 +0000 |
On 27 December 2012 18:00, <address@hidden> wrote:
> Date: Thu, 27 Dec 2012 03:48:16 -0800 (PST)
> From: ash <address@hidden>
> To: address@hidden
> Subject: strcmp with cell array does not work
> Message-ID: <address@hidden>
> Content-Type: text/plain; charset=us-ascii
>
> Hi all.
>
> I have two cell-arrays of strings and I need to compare them.
> they are :
>
> hdr.x
> ans =
> {
> [1,1] = aaa
>
> [2,1] = abc
>
> [3,1] = cde
>
> [4,1] = efg
>
> [5,1] = sdfg
>
> [6,1] = sd34
>
> }
>
> octave:16> hdr.y
> hdr.y =
> {
> [1,1] = sdfg
> [2,1] = yyy
> [3,1] = rrr
> [4,1] = erty6
> }
>
> when i use strcmp(hdr.y,hdr.x(5))
> it returns 0. why, if the first element of hdr.y is the same of the fifth of
> hdr.x ?
>
> If i use strcmp(hdr.y(1),hdr.x(5)) it returns 0 again!
> I'm confused.
> The same strcmp with the same arrays in matlab seem to work.
>
> Octave version 3.6.1
I can't reproduce with Octave 3.6.2
octave:1> hdr.x = {"aaa", "abc", "cde", "efg", "sdfg", "sd34"};
octave:2> hdr.y = {"sdfg", "yyy", "rrr", "erty6"};
octave:3> strcmp (hdr.y, hdr.x(5))
ans =
1 0 0 0
octave:4> strcmp (hdr.y(1), hdr.x(5))
ans = 1
Carnë