Wrong function interpretation on App Designer

1 visualizzazione (ultimi 30 giorni)
Chin-Hao Chang
Chin-Hao Chang il 29 Lug 2019
Risposto: Steven Lord il 20 Ago 2019
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 Commento
Walter Roberson
Walter Roberson il 29 Lug 2019
That command is the wrong one to figure out which encode is being used. You need
which encode(app.bag, newValidationData)

Accedi per commentare.

Risposte (2)

Subhadeep Koley
Subhadeep Koley il 20 Ago 2019
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 il 20 Ago 2019
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.

Categorie

Scopri di più su Data Import and Export in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by