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 Center および File ExchangeSudoku についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by