How to verify input only contains certain numbers?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ibro Tutic
el 12 de Jul. de 2017
Editada: Ibro Tutic
el 12 de Jul. de 2017
Lets say that users are required to enter the numbers: 35, 36, 37 in some order (b={'35', '36', '37'}). How would I go about verifying that these numbers were entered and not some other numbers and that each number was only entered once? So if the user entered 30,36,37 or 36,36,37 the program would error. The only acceptable input would be one where 35, 36, and 37 occur only once, in any order. Any ideas?
0 comentarios
Respuesta aceptada
per isakson
el 12 de Jul. de 2017
Editada: per isakson
el 12 de Jul. de 2017
An idea
>> b={'37', '36', '35'};
>> all( strcmp( unique( b ), {'35','36','37'} ) )
ans =
1
However, you have to check that length(unique(b))==3 before applying strcmp
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Troubleshooting in Polyspace Products for Ada en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!