Error using matlab.ui.​control.in​ternal.mod​el.Abstrac​tNumericCo​mponent/se​t.Value (line 111) 'Value' must be a double scalar.

I am trying to create a matlab app converting between different temperatures however when I try to run it for some reason the error message "Error using matlab.ui.control.internal.model.AbstractNumericComponent/set.Value (line 111) 'Value' must be a double scalar" comes out and I am not sure why. Please let me know if you u have any questions!

Respuestas (2)

Voss
Voss el 19 de Mayo de 2022
Editada: Voss el 19 de Mayo de 2022
Try it without converting to string
app.EditField.Value = Re;
because if app.EditField is a NumericEditField, its Value is a number, not a string.

7 comentarios

Still the same error? Verify that Re is a scalar.
I checked with TF = isscalar function and it confirmed that it is a scalar.
For debugging purposes, put a breakpoint at the line
app.EditField.Value = Re;
and query
size(Re)
class(Re)
disp(app.EditField.Value)
I put that into my code and no error message comes up now but the converted temperature doesn't show up in the output box
What were the outputs?
Note that the disp() in particular is intended to be before the assignment... though now that I think about it, it would be good to also have the same statement after the assignment.
if you change the code to
size(Re)
class(Re)
disp(app.EditField.Value)
app.EditField.Value = Re;
disp(app.EditField.Value)
Then what shows up in the command window?

Iniciar sesión para comentar.

Categorías

Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.

Productos

Versión

R2021a

Preguntada:

el 18 de Mayo de 2022

Comentada:

el 19 de Mayo de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by