App Designer: Temperature Unit Converter (Error using matlab.ui.​control.Ed​itField)

2 visualizaciones (últimos 30 días)
Error using matlab.ui.control.EditField/set.Value (line 98)
'Value' must be a character vector or a string scalar.
I am using Matlab app designer to create a unit converter. but i have error ;(
app.Type1 = app.FromDropDown.Value;
if strcmp (app.Type1,'Cesius')==1
if strcmp(app.Type2,'Cesius')==1
app.Tout=app.Tin;
app.OutputTemperatureEditField.Value=app.Tout;
elseif strcmp(app.Type2,'Fshrenheit')==1
app.Tout=app.Tin*(9/5)+32;
app.OutputTemperatureEditField.Value=app.Tout;
elseif strcmp(app.Type2,'Kelvin')==1
app.Tout=app.Tin+273.15;
app.OutputTemperatureEditField.Value=app.Tout;
elseif strcmp(app.Type2,'Rankine')==1
app.Tout=(app.Tin+273.15)*9/5;
app.OutputTemperatureEditField.Value=app.Tout;
end
elseif strcmp(app.Type1,'Fshrenheit')==1
if strcmp(app.Type2,'Cesius')==1
app.Tout=(app.Tin*-32)*5/9;
(error) app.OutputTemperatureEditField.Value=app.Tout;
elseif strcmp(app.Type2,'Fshrenheit')==1
app.Tout=app.Tin;
app.OutputTemperatureEditField.Value=app.Tout;
elseif strcmp(app.Type2,'Kelvin')==1
app.Tout=(app.Tin+459.67)*5/9;
app.OutputTemperatureEditField.Value=app.Tout;
elseif strcmp(app.Type2,'Rankine')==1
app.Tout=app.Tin+459.67;
app.OutputTemperatureEditField.Value=app.Tout;
end

Respuestas (1)

Avratanu Biswas
Avratanu Biswas el 27 de Nov. de 2020
Editada: Avratanu Biswas el 27 de Nov. de 2020
Hi,
Please try :
% Use num2str in all the cases
app.OutputTemperatureEditField.Value = num2str(app.Tout);
Cheers
Avra

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by