how do you check that a value input into your code is exactly 7 digits long before proceeding?
1 回表示 (過去 30 日間)
古いコメントを表示
in my code we enter a value that is seven digits long our school id's for example
idNumber = ('1234567');
how can i verify that this number is seven digits long using a loop?
1 件のコメント
per isakson
2019 年 2 月 15 日
編集済み: per isakson
2019 年 2 月 15 日
Why not
>> idNumber = ('1234567');
>> length(strtrim(idNumber))
ans =
7
>>
回答 (1 件)
Stephen23
2019 年 2 月 15 日
idNumber = '1234567';
assert(numel(idNumber)==7,'Wrong length ID number')
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!