having error on string for showing data on the app ui

1 次查看(过去 30 天)
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