MATLAB Answers

0

Wrong function interpretation on App Designer

Chin-Hao Chang さんによって質問されました 2019 年 7 月 29 日 3:43
最新アクティビティ Steven Lord
さんによって 回答されました 2019 年 8 月 20 日 15:20
I tried to use the function "encode" in order to create matrix of n-gram counts.
newValidationdata = preprocessText(app, app.UITable2.Data);
XNew = encode(app.bag, newValidationData);
preprocessText is the function I've defined for text cleaning in text classification and its class of output is tokenizedDocuments, whereas app.bag is the bag of words model I've loaded into App Designer.
However, after compiling the error message "Not enough input arguments" popped out. I typed
open('encode.m')
and realized the compiler have interpreted encode function as block encoder, which requires 4 input arguments, instead of document encoder:
encode(msg,n,k)
What really confused me was even the function suggestions (the text that appears automatically below as one is typing) displayed what I wanted but never compiled the right way:
encode(bag,words,options)
As a whole, the document encoder worked fine on MATLAB Command Window but unfortunately not on App Designer. How can I fix this problem?

  1 件のコメント

Walter Roberson
2019 年 7 月 29 日 5:41
That command is the wrong one to figure out which encode is being used. You need
which encode(app.bag, newValidationData)

サインイン to comment.

2 件の回答

回答者: Subhadeep Koley 2019 年 8 月 20 日 7:19

It is difficult to debug without the actual code, but you can temporarily remove the Communications Toolbox from MATLAB’s current path
Go to the Home tab, click Set Path, click the folder of the Communications Toolbox, and click Remove.
This does not delete the toolbox, but temporarily removes it from the current search path so that the functions in the toolbox doesn’t get executed anymore.
Later you can again add Communications Toolbox in the search path if necesserry.

  0 件のコメント

サインイン to comment.


Steven Lord
回答者: Steven Lord
2019 年 8 月 20 日 15:20

You've encountered one of the problem listed in the Limitation section of the MATLAB Compiler documentation. You wrote:
whereas app.bag is the bag of words model I've loaded into App Designer.
From that documentation page:
"Dependent functions can also be hidden from the dependency analyzer in .mat files that are loaded by compiled applications. Use the mcc -a argument or the %#function pragma to identify .mat file classes or functions that are supported by the load command."
The dependency analysis MATLAB Compiler performs to determine what needs to be included in your application doesn't know that it needs to package the constructor and methods for the class object included in your MAT-file. Use the -a argument or the %#function pragma to tell it to include the bagOfWords constructor file (you can find this using which -all bagOfWords) which also includes the code for the encode method of that class.

  0 件のコメント

サインイン to comment.



Translated by