Get value from field

I want to create an entryfield and read the numeric value in it. Icreated the field but cant get the number from it.

4 comentarios

Cris LaPierre
Cris LaPierre el 6 de En. de 2024
Editada: Matt J el 6 de En. de 2024
Value is a property of the edit field. Access it using dot notation. You can see examples here: https://www.mathworks.com/help/matlab/ref/uieditfield.html
There are a couple ways of creating edit fields. What does your code look like?
Mohammad Mohammad
Mohammad Mohammad el 6 de En. de 2024
thresholdField = uieditfield(fig, 'numeric', 'limits', [0, inf]);
thresholdField.Position = [0.25, 0.3, 0.1, 0.05];
thresholdValue = thresholdField.Value;
% Check if the threshold value is valid
if isnan(thresholdField.Value)
errordlg('Invalid threshold value. Please enter a numeric value.', 'Error', 'modal');
return;
end
Rik
Rik el 6 de En. de 2024
There doesn't seem to be anything wrong with this code, other than that you have no time to put in a value before it is retrieved.
Mohammad Mohammad
Mohammad Mohammad el 6 de En. de 2024
Error using uieditfield
'limits' is not a valid STYLE for uieditfield. STYLE must be 'text' or 'numeric'.
Error in createGUI (line 35)
thresholdField = uieditfield(fig, 'numeric', 'limits', [0, inf]);
it gives this error

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 6 de En. de 2024

0 votos

You would get that error if fig is a figure() instead of being a uifigure()

Categorías

Más información sobre Interactive Control and Callbacks en Centro de ayuda y File Exchange.

Productos

Versión

R2023b

Etiquetas

Preguntada:

el 6 de En. de 2024

Respondida:

el 6 de En. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by