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 CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by