how do you check that a value input into your code is exactly 7 digits long before proceeding?
1 view (last 30 days)
Show older comments
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 Comment
per isakson
on 15 Feb 2019
Edited: per isakson
on 15 Feb 2019
Why not
>> idNumber = ('1234567');
>> length(strtrim(idNumber))
ans =
7
>>
Answers (1)
Stephen23
on 15 Feb 2019
idNumber = '1234567';
assert(numel(idNumber)==7,'Wrong length ID number')
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!