Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
FIND

Subject: FIND

From: Jessica

Date: 21 Apr, 2011 17:48:05

Message: 1 of 16

Hi,

I have a cell variable:

ROI=data(:,5)
ROI =

    '-1'
    '-1'
    '3'

whos ROI
  Name Size Bytes Class Attributes

  ROI 3x1 192 cell

I am looking to locate all the -1s:

ROI_m1 = find(ROI == -1);

but get the error:

??? Undefined function or method 'eq' for input arguments of type 'cell'.

Can anyone suggest what conversion I need to use?
I've tried:
ROI=str2double(ROI);
ROI=char(ROI);
ROI=cell2mat(ROI);

but they do not work.
Thanks!

Subject: FIND

From: dpb

Date: 21 Apr, 2011 18:07:17

Message: 2 of 16

On 4/21/2011 12:48 PM, Jessica wrote:
...

> I have a cell variable:
>
> ROI=data(:,5)
> ROI =
> '-1'
> '-1'
> '3'
...

> ROI_m1 = find(ROI == -1);
>
> but get the error:
>
> ??? Undefined function or method 'eq' for input arguments of type 'cell'.
>
> Can anyone suggest what conversion I need to use?
...
 >> ROI ={ '-1'; '-1'; '3'};
 >> idx=findcellstr(ROI,'-1')
idx =
      1 2
 >>

--

Subject: FIND

From: Jessica

Date: 21 Apr, 2011 18:16:06

Message: 3 of 16

dpb <none@non.net> wrote in message <ioprog$lgd$1@speranza.aioe.org>...
> On 4/21/2011 12:48 PM, Jessica wrote:
> ...
>
> > I have a cell variable:
> >
> > ROI=data(:,5)
> > ROI =
> > '-1'
> > '-1'
> > '3'
> ...
>
> > ROI_m1 = find(ROI == -1);
> >
> > but get the error:
> >
> > ??? Undefined function or method 'eq' for input arguments of type 'cell'.
> >
> > Can anyone suggest what conversion I need to use?
> ...
> >> ROI ={ '-1'; '-1'; '3'};
> >> idx=findcellstr(ROI,'-1')
> idx =
> 1 2
> >>
>
> --


The problem is that ROI is a variable from a loop so I cannot just rewrite it (I have many of them and the list can be much longer). That is why I am looking to convert the entire variable. Any other ideas?

Subject: FIND

From: dpb

Date: 21 Apr, 2011 19:17:00

Message: 4 of 16

On 4/21/2011 1:16 PM, Jessica wrote:
...

> The problem is that ROI is a variable from a loop so I cannot just
> rewrite it (I have many of them and the list can be much longer). That
> is why I am looking to convert the entire variable. Any other ideas?

Show what you're actually trying to do; it's not clear to me why you
think findcellstr() isn't the tool for finding strings in cells...

--

Subject: FIND

From: Matt J

Date: 21 Apr, 2011 19:31:04

Message: 5 of 16

dpb <none@non.net> wrote in message <iopvr5$v93$1@speranza.aioe.org>...
> On 4/21/2011 1:16 PM, Jessica wrote:
> ...
>
> > The problem is that ROI is a variable from a loop so I cannot just
> > rewrite it (I have many of them and the list can be much longer). That
> > is why I am looking to convert the entire variable. Any other ideas?
>
> Show what you're actually trying to do; it's not clear to me why you
> think findcellstr() isn't the tool for finding strings in cells...
===================

On a side note, where does one obtain this tool? It doesn't seem to be part of the usual MATLAB distribution.

Subject: FIND

From: dpb

Date: 21 Apr, 2011 19:38:14

Message: 6 of 16

On 4/21/2011 2:31 PM, Matt J wrote:
> dpb <none@non.net> wrote in message <iopvr5$v93$1@speranza.aioe.org>...
>> On 4/21/2011 1:16 PM, Jessica wrote:
>> ...
>>
>> > The problem is that ROI is a variable from a loop so I cannot just
>> > rewrite it (I have many of them and the list can be much longer). That
>> > is why I am looking to convert the entire variable. Any other ideas?
>>
>> Show what you're actually trying to do; it's not clear to me why you
>> think findcellstr() isn't the tool for finding strings in cells...
> ===================
>
> On a side note, where does one obtain this tool? It doesn't seem to be
> part of the usual MATLAB distribution.

 >> which findcellstr
C:\matlabR12\toolbox\matlab\strfun\findcellstr.m
 >>

--

Subject: FIND

From: Matt J

Date: 21 Apr, 2011 19:44:05

Message: 7 of 16

dpb <none@non.net> wrote in message <ioq12v$3af$1@speranza.aioe.org>...
>
> > On a side note, where does one obtain this tool? It doesn't seem to be
> > part of the usual MATLAB distribution.
>
> >> which findcellstr
> C:\matlabR12\toolbox\matlab\strfun\findcellstr.m
====================


Not me (R2010b):

>> which findcellstr
'findcellstr' not found.

Subject: FIND

From: Matt J

Date: 21 Apr, 2011 20:02:05

Message: 8 of 16

"Jessica" wrote in message <iopqkl$n5$1@fred.mathworks.com>...
>
> Can anyone suggest what conversion I need to use?
> I've tried:
> ROI=str2double(ROI);
============

str2double ought to have worked, e.g.

>> ROI={'-3','-2','-1'}
>> ROI_m1 = find(str2double(ROI) == -1)

ROI_m1 =

     3

Subject: FIND

From: Steven_Lord

Date: 21 Apr, 2011 20:40:44

Message: 9 of 16



"dpb" <none@non.net> wrote in message news:ioq12v$3af$1@speranza.aioe.org...
> On 4/21/2011 2:31 PM, Matt J wrote:
>> dpb <none@non.net> wrote in message <iopvr5$v93$1@speranza.aioe.org>...
>>> On 4/21/2011 1:16 PM, Jessica wrote:
>>> ...
>>>
>>> > The problem is that ROI is a variable from a loop so I cannot just
>>> > rewrite it (I have many of them and the list can be much longer). That
>>> > is why I am looking to convert the entire variable. Any other ideas?
>>>
>>> Show what you're actually trying to do; it's not clear to me why you
>>> think findcellstr() isn't the tool for finding strings in cells...
>> ===================
>>
>> On a side note, where does one obtain this tool? It doesn't seem to be
>> part of the usual MATLAB distribution.
>
> >> which findcellstr
> C:\matlabR12\toolbox\matlab\strfun\findcellstr.m

I don't see that in R12, so I'm guessing it isn't a MathWorks file. To
confirm that, please check if that file has a copyright line that references
The MathWorks, Inc.

If it doesn't, the help text may indicate who wrote the file.

This type of confusion is one reason I recommend not putting user-created
files in a directory under $MATLABROOT/toolbox (although there are other
reasons as well.)

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: FIND

From: dpb

Date: 21 Apr, 2011 22:04:19

Message: 10 of 16

On 4/21/2011 3:40 PM, Steven_Lord wrote:
...

>>> On a side note, where does one obtain this tool? It doesn't seem to be
>>> part of the usual MATLAB distribution.
>>
>> >> which findcellstr
>> C:\matlabR12\toolbox\matlab\strfun\findcellstr.m
>
> I don't see that in R12, so I'm guessing it isn't a MathWorks file. To
> confirm that, please check if that file has a copyright line that
> references The MathWorks, Inc.
...
 >> type findcellstr.m

function ind = findcellstr(cstr,str)
%FINDCELLSTR Finds occurrences of string in cell array of strings.
% IND = FINDCELLSTR(CSTR,STR) finds the indices of the cell array of
strings
% CSTR where CSTR{IND(I)} contains STR, for I from 1 to length(IND).

% Copyright 1988-2000 The MathWorks, Inc.
% $Revision: 1.6 $

AFAIK no fairies have been here during the nights...I have no other
knowledge of it; I certainly don't recall munging on another file and
creating it myself and the machine sits in home office and has since it
was purchased...

--

Subject: FIND

From: Matt J

Date: 22 Apr, 2011 09:52:04

Message: 11 of 16

dpb <none@non.net> wrote in message <ioq9l0$nv4$1@speranza.aioe.org>...
>
> >> type findcellstr.m
>
> function ind = findcellstr(cstr,str)
> %FINDCELLSTR Finds occurrences of string in cell array of strings.
> % IND = FINDCELLSTR(CSTR,STR) finds the indices of the cell array of
> strings
> % CSTR where CSTR{IND(I)} contains STR, for I from 1 to length(IND).
>
> % Copyright 1988-2000 The MathWorks, Inc.
> % $Revision: 1.6 $
>
> AFAIK no fairies have been here during the nights...I have no other
> knowledge of it; I certainly don't recall munging on another file and
> creating it myself and the machine sits in home office and has since it
> was purchased...
=====================

Puzzling. But could you type the full code? We may as well have it, I guess. Or is the implementation a .bi file?

Subject: FIND

From: dpb

Date: 22 Apr, 2011 12:11:18

Message: 12 of 16

On 4/22/2011 4:52 AM, Matt J wrote:
...

> Puzzling. But could you type the full code? We may as well have it, I
> guess. Or is the implementation a .bi file?

Hmmm....am supposed to do that w/ what (afaik) is a real TMW copyright?
  I've no problem if Steven says ok but think I'll wait to see if he nods.

But it's not very complex (and maybe somehow there got to be a trial
function that wasn't in later releases in an update, I don't know?);
it's just a for...end loop around a findstr() call on the contents of
the cell array (buried in a try..end clause for error handling of
non-string entries.

--

Subject: FIND

From: Steven_Lord

Date: 22 Apr, 2011 13:41:25

Message: 13 of 16



"dpb" <none@non.net> wrote in message news:iorr95$2ht$1@speranza.aioe.org...
> On 4/22/2011 4:52 AM, Matt J wrote:
> ...
>
>> Puzzling. But could you type the full code? We may as well have it, I
>> guess. Or is the implementation a .bi file?
>
> Hmmm....am supposed to do that w/ what (afaik) is a real TMW copyright?
> I've no problem if Steven says ok but think I'll wait to see if he nods.

Can you send me the file so that I can try to figure out its history? When
you do, can you also send me the output of VER? The VER output will let me
check if maybe someone in Technical Support sent you the file when you asked
them a question about locating strings in a cellstr. [I know, it's a bit of
a stretch, but when I was in Technical Support I sent out examples I'd
written that I'm guessing may still be floating around people's code bases.]

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: FIND

From: dpb

Date: 22 Apr, 2011 17:57:45

Message: 14 of 16

On 4/22/2011 8:41 AM, Steven_Lord wrote:
...

> Can you send me the file so that I can try to figure out its history?
...

You (or soon will) have mail... :)

--

Subject: FIND

From: Steven_Lord

Date: 22 Apr, 2011 19:23:09

Message: 15 of 16



"dpb" <none@non.net> wrote in message news:iosfim$m80$1@speranza.aioe.org...
> On 4/22/2011 8:41 AM, Steven_Lord wrote:
> ...
>
>> Can you send me the file so that I can try to figure out its history?
> ...
>
> You (or soon will) have mail... :)

I received it and I will try to figure out where that file came from. It may
take me a little while, so I probably won't have the answer before Monday at
the earliest.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: FIND

From: dpb

Date: 22 Apr, 2011 22:41:10

Message: 16 of 16

On 4/22/2011 2:23 PM, Steven_Lord wrote:
...

> I received it and I will try to figure out where that file came from. It
> may take me a little while, so I probably won't have the answer before
> Monday at the earliest.

Don't stay over Easter weekend on _MY_ account thinking I'll be waiting,
Steven... :)

OK, in addition to looking for a file download, I let grep run over the
entire local disk looking for "findcellstr" -- the only hits were in the
working directories for the postings in this thread and the e-mail
working files so I've no at least easily traceable remnants here of
having downloaded it or whatever...think that indicates it wasn't mailed
because I've not compacted or deleted the download attachment files
since loading the e-mail client and generally wouldn't go out of way to
do anything but save a copy of an attachment to a working directory
rather than be careful to actually move that attachment copy itself...

I'm at a loss because I really don't recall it being a subject of much
concern before and I only came across it in this thread in using lookfor
to remind myself of the cell function list. The one clue that it wasn't
in the initial distribution despite my not remembering adding it is that
it isn't listed in contents.m in strfun subdirectory so I suppose I did
find it somewhere and just don't recollect doing so (any more, that
wouldn't be at all unusual :) ).

Enjoy the weekend...

--

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us