My first user-input prompt is to enter a number (say, x). What should I write if my next message box MUST contain the same number of prompt questions as x?

2 visualizaciones (últimos 30 días)
Hi! My first user-input prompt is to enter a number (say, x). What should I write (code) if my next message box MUST contain the same number of prompt questions as x?

Respuesta aceptada

Steven Lord
Steven Lord el 22 de Ag. de 2022
I'd use a string array. I'm going to hard code the value of n to keep this example simple, but you could query for it using a dialog.
n = 5;
questions = "Enter the value for element number " + (1:n);
inputdlg(questions)
  1 comentario
Matty
Matty el 5 de Sept. de 2022
Here is my code, but it is discontinuous. That is, after a user input in the first message box, there is still a need to input the same in the Command Window. How can I fix this?
prompt="Enter Number of Factors ";
inputdlg(prompt);
x=input(prompt);
n = x;
questions = "Enter the level for Factor " + (1:n);
inputdlg(questions);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by