Lets Learn together... Happy Reading

" Two roads diverged in a wood, and I,
I took the one less traveled by,
And that has made all the difference "-Robert Frost

Array Search

Let's search the cell array and find the index. This simple example will help to find the index in cell array of large size.

names={'Hilda' 'Helen' 'Ada'; 'Matthew' 'Jenny' 'Justin'; 'Agnes' 'Merlin' 'Mark';}

names = 

    'Hilda'      'Helen'     'Ada'   
    'Matthew'    'Jenny'     'Justin'
    'Agnes'      'Merlin'    'Mark'  

I need to know whether the name 'Justin' exists in this cell array

find(strcmp(names,'Justin')==1)

ans =

     8

Let me retrieve the name 'Justin'  , using the index

names{8}

ans =

Justin


like button Like "IMAGE PROCESSING" page

0 comments:

Enjoyed Reading? Share Your Views

Previous Post Next Post Home
Google ping Hypersmash.com