Wrong function interpretation on App Designer

1 回表示 (過去 30 日間)
Chin-Hao Chang
Chin-Hao Chang 2019 年 7 月 29 日
回答済み: Steven Lord 2019 年 8 月 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
Walter Roberson 2019 年 7 月 29 日
That command is the wrong one to figure out which encode is being used. You need
which encode(app.bag, newValidationData)

サインインしてコメントする。

回答 (2 件)

Subhadeep Koley
Subhadeep Koley 2019 年 8 月 20 日
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.

Steven Lord
Steven Lord 2019 年 8 月 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.

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by