access to string data in cell array-

2 次查看(过去 30 天)
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?
anscell{1,1}=
'LThand.jpg'
'aa1=strcmp('LT',anscell{1:5,1}(1:2));'
because for now I get an error-
Bad cell reference operation.
Error in a (line 5)
aa1=strcmp({'LT'},anscell{1:5,1}(1:2));

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by