App Designer: Temperature Unit Converter (Error using matlab.ui.control.EditField)
2 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Avratanu Biswas
on 27 Nov 2020
Edited: Avratanu Biswas
on 27 Nov 2020
Hi,
Please try :
% Use num2str in all the cases
app.OutputTemperatureEditField.Value = num2str(app.Tout);
Cheers
Avra
0 Comments
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!