Function to utilize user input on a GUI system?

6 visualizaciones (últimos 30 días)
Olivia Rose
Olivia Rose el 21 de Abr. de 2022
Respondida: Riccardo Scorretti el 21 de Abr. de 2022
This is the first time I've had to make a gui and I'm not sure how to fix this. I have an edit box to be used by the user to input a value, then a push button is used that sets off the calculations, then graphs and answers are displayed. I have everything working expect for the input. I thought the input part was working but apparently not, and I realize I'm not sure how to go about it.
m=input('Please provide the weight of the particle: \n');
That's the original code, but I need it translated so that it works within the gui correctly.

Respuesta aceptada

Riccardo Scorretti
Riccardo Scorretti el 21 de Abr. de 2022
If you want to ask such a question by a GUI dialog, you can use the function inputdlg. For instance:
m = inputdlg('Please provide the weight of the particle', 'Settings');
m = str2num(m{1})
Then, when using GUI you ough to take into account the case when the user cancels the operation, for instance:
m = inputdlg('Please provide the weight of the particle', 'Settings');
if isempty(m)
msgbox('Operation cancelled by the user');
return
else
m = str2num(m{1})
end

Más respuestas (0)

Categorías

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

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by