Borrar filtros
Borrar filtros

User input fractions or operations

3 visualizaciones (últimos 30 días)
Chesus
Chesus el 5 de Sept. de 2023
Respondida: Walter Roberson el 6 de Sept. de 2023
I want to ask for an input in which the user is able to introduce a fraction
like:
x=input('Hi: ')
Hi: 1/3
x=
0,3333333333333
Can I do that?

Respuesta aceptada

Walter Roberson
Walter Roberson el 6 de Sept. de 2023
Yes. When you use input() without the 's' option, then whatever the user inputs will be executed and the result will be stored in the output variable.
For example the user could also have input sinpi((1:10)/7) and the expression would be evaluated and the results put into the variable.
The variable will not have access to the input characters in this case. If you need access to the input characters then you need to use the 's' option.

Más respuestas (0)

Categorías

Más información sobre Desktop en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by