Encode function not enough input arguments error in App Designer but works fine in MATLAB script
1 次查看(过去 30 天)
显示 更早的评论
I was trying to write a GUI for text classification by app designer. I've also written a script (.m file) to do the basic functions testing.
In the script, everything worked out perfectly as I wanted. Part of the code is shown as below:
newValidationdata = preprocessText(validationData); %validationdata is a 80X1 string array; preprocessText is a function I've defined for text cleaning.
XNew = encode(bag, newValidationData); %bag is a bagOfWords variable
[labelsNew, score, cost] = predict(mdl, XNew); %mdl is the resulting model after training
I passed two arguments to the encode function and nothing went wrong. The encode function was executable in the command window.
In App Designer I created a classify button and its callback function is performing the same operation mentioned above in the code:
bag = load('bag.mat');
mdl = load('mdl.mat');
newValidationData = preprocessText(app, app.UITable2.Data);
XNew = encode(bag, newValidationData);
app.UITable3.Data = predict(mdl, XNew);
After running the app, however, it shows the message: "Error using encode (line 19) Not enough input arguments." How's that possible if the code works on MATLAB but not in App Designer?
I've tried to add "app" a the first argument of encode.
encode(app, bag, newValidationData);
As it turned out, a different message popped out: "Undefined function 'floor' for input arguments of type 'struct'. Error in encode (line 51) if (floor(n) ~= n) || (n<1)" How should I resolve this problem?
5 个评论
Walter Roberson
2019-7-29
You might suspect that, but if you were to post the output I requested, then we would *know* rather than just suspecting.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!