access to string data in cell array-

11 views (last 30 days)
alex on 15 Oct 2012
I have read the matlab help on it and still have some questions-
with strings in the cell array- I want to enter to just the first two chars of the string, how can I do that?
because for now I get an error-
Bad cell reference operation.
Error in a (line 5)

Accepted Answer

Matt Fig
Matt Fig on 16 Oct 2012
Edited: Matt Fig on 16 Oct 2012
Try this:
anscell= {'LTlHSPRY','LTsalove','ohw','sdaer','siht','LTRDUDE'}
aa1 = cellfun(@(x) strcmp('LT',x(1:2)),anscell)

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!