Prev: Simulink Index Vector can't access first element
Next: MLAPPClass times out in a multi threaded C# application
From: Matt Dunham on 27 Feb 2010 13:52 Luna Moon <lunamoonmoon(a)gmail.com> wrote in message <91f4462c-6998-451d-a192-5cb540e7e99b(a)k9g2000vbl.googlegroups.com>... > Hi all, > > If I have a cell called A, > > let's say A={'aa', 'bb', 'cc'}, > > what's the most efficient way to do > > find(A=='aa')? > > It seems getting an error in Matlab? find(cellfun(@(s)strcmp(s, 'aa'), A)
From: Jan Simon on 27 Feb 2010 15:29
Dear Luna! > A={'aa', 'bb', 'cc'}, > what's the most efficient way to do > find(A=='aa')? > > It seems getting an error in Matlab? "It seems"?! Please read and post the exact error message. It tells exactly what the problem is. Try this: find(strcmp(A, 'aa')) In a lot of cases logical indexing is much faster and the FIND can be omitted. Good luck, Jan |