[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "find" equivalent for strings?
From: |
Tom Holroyd |
Subject: |
Re: "find" equivalent for strings? |
Date: |
Tue, 13 Sep 2005 17:38:53 -0400 |
User-agent: |
Mozilla Thunderbird 1.0.6-1.1.fc3 (X11/20050720) |
In Octave 2.9.3 you can just do
octave:1> m = { 'bob', 'fred', 'bob', 'larry' }
m =
{
[1,1] = bob
[1,2] = fred
[1,3] = bob
[1,4] = larry
}
octave:2> strcmp(m, 'bob')
ans =
1 0 1 0
Mike Miller wrote:
> Now I want to determine which elements of x consist of "bob" (so I
want the vector [1,4,5] returned) ...
Make that
octave:3> find(strcmp(m, 'bob'))
ans =
1 3
--
Dr. Tom Holroyd
"A man of genius makes no mistakes. His errors are volitional and
are the portals of discovery." -- James Joyce
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------