필터 지우기
필터 지우기

access to string data in cell array-

조회 수: 1 (최근 30일)
alex
alex 2012년 10월 15일
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