having error on string for showing data on the app ui

조회 수: 1 (최근 30일)
Kiat Tsen Lim
Kiat Tsen Lim 2023년 1월 18일
댓글: dpb 2023년 1월 19일
featuresTest = vertcat(featuresTest{:});
featuresTest = rmmissing(featuresTest);
featuresTest{:,2:15} = (featuresTest{:,2:15}-app.mn)./app.sd;
resulttable= app.HelperTestKNNClassifier(app.trainedClassifier, featuresTest);
app.MatchingPercentageEditField.Value=string(resulttable.ConfidencePercentage);
if str2double(string(resulttable.ConfidencePercentage))>70
app.StatusEditField.Value = "person authorized";
app.SpeakerIdentityEditField.Value=string(resulttable.PredictedSpeaker);
if string(resulttable.PredictedSpeaker) == "Jens_Stoltenberg"
elseif string(resulttable.PredictedSpeaker) == "Julia_Gillard"
elseif string(resulttable.PredictedSpeaker) == "Magaret_Tarcher"
elseif string(resulttable.PredictedSpeaker) == "Nelson_Mandela"
so whenever i run this code for my speech processing, I will have a problem showing the error "Error using matlab.ui.control.EditField/set.Value (line 99)
'Value' must be a character vector or a string scalar. "
on the line app.MatchingPercentageEditField.Value=string(resulttable.ConfidencePercentage);
any guru here that can help me, thanks !

답변 (1개)

dpb
dpb 2023년 1월 18일
이동: dpb 2023년 1월 18일
Per <uieditfield> documentation,
Value Text in edit field
'' (default) | character vector | string scalar
Text in the edit field, specified as a character vector or string scalar. MATLAB® displays the text as a single line. If you want to allow multiple lines of text, use a text area component instead of an edit field.
Your .ConfidencePercentage table variable is a vector of values, not a single value.
Do you really want the user to be able to modify these or just display them? Either way, the uieditfield component can't display but a single string.
  댓글 수: 4
Kiat Tsen Lim
Kiat Tsen Lim 2023년 1월 19일
so if I use a text area component, do i still need to put string before (resulttable.confidencepercentage)?
For example:
app.MatchingPercentageEditField.Value=string(resulttable.ConfidencePercentage);
dpb
dpb 2023년 1월 19일
The .Value property is text, yes...but the uitable can handle the table directly with variable names, etc., etc., ... Don't know your application, of course, but from afar would seem to be a good choice

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Sudoku에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by