How can I return an error in a loop format if user does not enter inputs in an array format?

Respuestas (1)

use the input option 's' to receive the characters the user entered. Check to be sure that the characters entered match the syntaxes you wish to permit such as requiring that it be of the format
optional whitespace
[
optional whitespace
one or more decimal digits
optional whitespace
comma
optional whitespace
one or more decimal digits
optional whitespace
]
optional whitespace
This check is easy to do using regexp()
Then convert the sequences of digits from characters to numeric
This assumes that you wish to enforce that they use a comma between the parts, refusing (for example) [2 8] for not being in the form you instruct because it does not have the comma.

Categorías

Más información sobre Entering Commands en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 19 de Sept. de 2022

Respondida:

el 19 de Sept. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by