Effacer les filtres
Effacer les filtres

Function to utilize user input on a GUI system?

1 vue (au cours des 30 derniers jours)
Olivia Rose
Olivia Rose le 21 Avr 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.

Réponse acceptée

Riccardo Scorretti
Riccardo Scorretti le 21 Avr 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

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by