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 CenterFile Exchange에서 Develop 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