How to check the numbers of characters of a string?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
e.g I have a string, abcde. And I need a checker to check whether the string has 5 characters before executing a command.
0 Kommentare
Akzeptierte Antwort
Pedro Villena
am 31 Okt. 2012
Bearbeitet: Pedro Villena
am 31 Okt. 2012
str = num2str([17;10],'%05i')
if length(str(1,:))==5,
%%%here is your command
end
or
str = num2str([17;10],'%05i')
if numel(str(1,:))==5,
%%%here is your command
end
3 Kommentare
Matt Fig
am 31 Okt. 2012
Better to use NUMEL, for generality.
S = ['ertyu';'poiuy';'lkjhg';'nbvcx']
length(S)
numel(S)
Weitere Antworten (4)
manoj saini
am 31 Okt. 2012
>>a='string'; >>n=length(a) so n will return length of a string
0 Kommentare
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!