Matlab: using strfind to get an exact match

I have a 1x5 cell that might look something like this:

A = {'asd','pqr','asd 123','pqr123','asd 1','dfg',}

When I do this:

strfind(A,'asd')

I get

[1]    []    [1]    []    [1]    []

However, I want an exact match. that is, I wish

[1]    []    []    []    []    []

How can I reach higher?

+3
source share
1 answer

Use strcmp (case sensitive) or strcmpi (case insensitive).

strcmp(A,'asd');

gives the following ans:

1     0     0     0     0     0
+10
source

All Articles