Cannot load 'ClassificationKNN' in a compiled executable, issue with classdef?
조회 수: 10 (최근 30일)
이전 댓글 표시
I have a model that was trained using the fitcknn function.
I save it as a *.mat file, load it into my Matlab programs and it works fine.
I then compile the code, run it, and when it tries to load the aforementioned mat file, it gives me a warning saying
Warning: Variable 'b' originally saved as a ClassificationKNN cannot be instantiated as an object and will be read in as a uint32.
I've found this Matlab question with someone having the same problem http://au.mathworks.com/matlabcentral/newsreader/view_thread/261903
But they are using their own class, it was solved because his classdef wasn't on the path, so putting it there solved his problem.
So do I need to find the original Matlab classdef for ClassificationKNN and somehow make it accesabile to my executable file? If so how? Or am I way off?
Thanks for any help in advance!
댓글 수: 0
채택된 답변
Steven Lord
2015년 7월 2일
When you LOAD an object from a MAT-file, MATLAB needs the class definition to tell it how to convert the raw data into an object. When you create a compiled application, MATLAB analyzes your code to determine what functions need to be part of that compiled application. I'm pretty sure that analysis doesn't "look into" MAT-files to determine what functions it may need when that MAT-file is loaded.
I think using the %#function pragma to include the object constructor (ClassificationKNN) or explicitly listing the class definition file as a required file using the Application Compiler app will resolve this issue for you.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Compiler에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!