Filter löschen
Filter löschen

access to string data in cell array-

1 Ansicht (letzte 30 Tage)
alex
alex am 15 Okt. 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?
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));

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Cell Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by