How to check the numbers of characters of a string?
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Pedro Villena
2012 年 10 月 31 日
編集済み: Pedro Villena
2012 年 10 月 31 日
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 件のコメント
Matt Fig
2012 年 10 月 31 日
Better to use NUMEL, for generality.
S = ['ertyu';'poiuy';'lkjhg';'nbvcx']
length(S)
numel(S)
その他の回答 (4 件)
manoj saini
2012 年 10 月 31 日
>>a='string'; >>n=length(a) so n will return length of a string
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!