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

2 ビュー (過去 30 日間)
duna saleh
duna saleh 2020 年 11 月 14 日
編集済み: Avratanu Biswas 2020 年 11 月 27 日
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

回答 (1 件)

Avratanu Biswas
Avratanu Biswas 2020 年 11 月 27 日
編集済み: Avratanu Biswas 2020 年 11 月 27 日
Hi,
Please try :
% Use num2str in all the cases
app.OutputTemperatureEditField.Value = num2str(app.Tout);
Cheers
Avra

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by