how do you check that a value input into your code is exactly 7 digits long before proceeding?

1 回表示 (過去 30 日間)
Kyle Snowden
Kyle Snowden 2019 年 2 月 15 日
回答済み: Stephen23 2019 年 2 月 15 日
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
per isakson 2019 年 2 月 15 日
編集済み: per isakson 2019 年 2 月 15 日
Why not
>> idNumber = ('1234567');
>> length(strtrim(idNumber))
ans =
7
>>

サインインしてコメントする。

回答 (1 件)

Stephen23
Stephen23 2019 年 2 月 15 日
idNumber = '1234567';
assert(numel(idNumber)==7,'Wrong length ID number')

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by