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!

采纳的回答

Steven Lord
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 CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by