For Programmers: Free Programming Magazines  


Home > Archive > Matlab > December 2005 > Re: how to locate some specific value in a cell ar









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: how to locate some specific value in a cell ar
PB

2005-12-18, 7:58 am

Zhihua LI wrote:
>
>
> hi,netters
>
> i have a cell array X like this:
>
> [AX3]
> [BS2]
> [ZZL]
> ....
>
> i know somewhere in X the value is "ZZW". i wanna locate its
> postion.
>
> normally if in an array i use find(X=="ZZW"). but in the cell array
> case i got an error message: '==' is not defined for values of
> class
> 'cell'.
>
> does anyone know how to crack this?
>
> thanks a lot!


Some solutions:

a={'AAB';'ZZW';'ZZK';'ZZL';'SL3'}
str='ZZW'

% Pick one depending on wished output format
c1=strcmp(a,str)
c2=strfind(a,str)
c3=strmatch(str,a)

hth
/PB
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com