having error on string for showing data on the app ui

1 Ansicht (letzte 30 Tage)
Kiat Tsen Lim
Kiat Tsen Lim am 18 Jan. 2023
Kommentiert: dpb am 19 Jan. 2023
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 !

Antworten (1)

dpb
dpb am 18 Jan. 2023
Verschoben: dpb am 18 Jan. 2023
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 Kommentare
Kiat Tsen Lim
Kiat Tsen Lim am 19 Jan. 2023
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 am 19 Jan. 2023
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Sudoku finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by