How to eliminate, function not found warnings when using Matlab Runtime

조회 수: 15 (최근 30일)
I have built a .net library using Matlab R2018b, which uses a Classification Learner trained model of type SVM (CompactClassificaitonECOC). While using the classification from within Matlab works fine, when I use the .net library, I get all sorts of warnings for it, which say "Could not find appropriate function on path loading function handle..." e.g.
Warning: Could not find appropriate function on path loading function handle C:\Program Files\MATLAB\R2018b\toolbox\stats\mlearnapp\+mlearnapp\+internal\+model\DatasetSpecification.m>@(x)exportableModel.predictFcn(predictorExtractionFcn(x))
Warning: Could not find appropriate function on path loading function handle C:\Program Files\MATLAB\R2018b\toolbox\stats\mlearnapp\+mlearnapp\+internal\+model\+transformation\TrainedManualFeatureSelection.m>@(x)decoratedPredictFunction(featureSelectionFunction(x))
Warning: Could not find appropriate function on path loading function handle C:\Program Files\MATLAB\R2018b\toolbox\stats\mlearnapp\+mlearnapp\+internal\+model\DatasetSpecification.m>@(t)t(:,predictorNames)
> In setupClassification>@(x)exportableModel.predictFcn(predictorExtractionFcn(x))
and so on..
Please help in resolving this. I am using Matlab Runtime 2018b as well.

채택된 답변

Steven Lord
Steven Lord 2020년 1월 2일
From your description it sounds like you're loading an instance of an object from a MAT-file in your application.
If you're loading an object into your standalone application without giving any indication in the code of the application itself that the definition of the object will need to be included in the application, the dependency analysis may not include it in the application. [See the Tip in the "Fixing Callback Problems: Missing Functions" section on this documentation page, which though it's for the most recent release I believe is still applicable for older releases.]
You're probably going to need to use the %#function pragma or the -a option to include the definition of the class in your application, or you'd need to indicate in the code itself (say by calling the class constructor) something that informs the dependency analysis routine that it needs to include the class definition.
  댓글 수: 3
Steven Lord
Steven Lord 2020년 1월 2일
A MAT-file is not a function. You need to tell MATLAB that it needs to include the definition of the class in the application, so when it loads the object from the MAT-file MATLAB knows how to create it.
If you tell me you're bringing a dessert (the object) to a potluck dinner, you should tell me (MATLAB, mcc) that it needs to be kept cold before you bring it (when you compile the application) so I can make sure I have ice packs or a small refrigerator (the class definition) available. If not, at best we end up with ice cream soup. At worst, we have to throw it away lest everyone ends up with food poisoning.
What's the class of model.trainedModel? Use that class name in your pragma. [You may also need to specify the name of the MAT-file in your call to mcc, I'm not certain of that off the top of my head. Regardless it shouldn't hurt.]
Sameer Raheja
Sameer Raheja 2020년 1월 3일
Understood. So I was doing the pragma include you suggested (i.e. ClassificationEnsemble) earlier, and I forgot that I had changed my TrainedModel to ClassificationSVM and missed changing the pragma altogether. However even after doing a %#function ClassificationSVM, and including the path to its definition in mcc, I was still getting the warnings.
Apparently, one cannot use predictFcn in such cases of exportable TrainedModels, which is what the Matlab warning is about when loading such TrainedModels, i.e.
Warning: Could not find appropriate function on path loading function handle C:\Program Files\MATLAB\R2018b\toolbox\stats\mlearnapp\+mlearnapp\+internal\+model\DatasetSpecification.m>@(x)exportableModel.predictFcn(predictorExtractionFcn(x))
And no pragma or mcc path includes get rid of this warning.
However, changing my implementation of using this trained model from:
disp = trainedModel.predictFcn(tt);
to:
disp = predict(trainedModel.ClassificationSVM, tt);
got rid of my other warnings. Of course, I had to do a pragma include i.e.:
%#function ClassificationSVM
Thanks for your help.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2020년 1월 2일
Some functions cannot be included in a compiled executable. Usually they are applets with a user interface like the Classification Learner, Color Thresholder, Image labeler, etc.. Check the excluded files log file to see what files it cannot include. Call tech support if you still have problems that you think are not related to that.
  댓글 수: 2
Sameer Raheja
Sameer Raheja 2020년 1월 2일
편집: Sameer Raheja 2020년 1월 2일
Thanks for the response. Apparently, that does not seem to be the issue. The mccExcludedFiles document is empty and the PackagingLog does not state any such issues. Is there somewhere, I should be looking?
Image Analyst
Image Analyst 2020년 1월 2일
Then I don't know. You'll have to call tech support to solve this one.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by