Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab: using strfind to get exact match

Tags:

matlab

I have a 1x5 cell which might look something like:

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

When I do:

strfind(A,'asd')

I get

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

However, I want an exact match. i.e. I desire

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

How do I achieve above ?

like image 258
Zanam Avatar asked Dec 19 '22 19:12

Zanam


1 Answers

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

strcmp(A,'asd');

gives the following ans:

1     0     0     0     0     0
like image 65
Autonomous Avatar answered Jan 03 '23 22:01

Autonomous