Cannot load 'ClassificationKNN' in a compiled executable, issue with classdef?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Steven Lord
am 2 Jul. 2015
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Compiler finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!