0

I've trained a linear SVM classifier using the Classification Learner app, and exported the model to a .mat file. I'm attempting to translate this algorithm to C using MATLAB Coder, but am getting an error.

I'm not sure if I'm approaching the problem correctly, but my current approach is to load the .mat file as I would do in MATLAB, and then call the classification prediction function using values that are passed in (this assumes that using load() would normally work in MATLAB Coder, of which I'm not sure). When running the "Check for issues" step in MATLAB Coder, the following error is triggered:

Found unsupported class for variable using function 'load'. MATLAB class 'ClassificationSVM' found at 'classifier.trainedClassifier.ClassificationSVM' is unsupported.

Use the command 'whos -file classifierOptimal.mat' to view the variables in the MAT file.

It would appear that the MATLAB class used for classification is unsupported in MATLAB Coder.

How do I translate this classification algorithm for use outside of MATLAB?

enter image description here

2 Answers 2

0

There are two things here. It seems to me that you're trying to generate an executable with:

  • Loading an external mat file
  • External library that needs to be compiled in to your executable

I would read this article about finding mat files for the first issue: http://blogs.mathworks.com/loren/2008/08/11/path-management-in-deployed-applications/

I would carefully try to avoid dynamic (i.e. loaded at run time language constructs) while I grasp how the compiler works. Loading an instance from a MAT file asking for trouble.

You're trying to do too many things at the same time, simplify your approach and see what happens.

Sign up to request clarification or add additional context in comments.

3 Comments

Loading the .mat file seems to work; the issue is that the types defined in the .mat file aren't supported by Coder. Do you have any suggestions on a method that doesn't rely on using the .mat file?
Hard to say without knowing where: classifierOptimal.mat came from, who created it, and who wrote predictFcn, and can it be changed into a standard Matlab function or a mex file?
The .mat file was generated using the Classification Learner app.
0

Unfortunately, it appears that code generation for SVM routines is not supported:

MATLAB Answers

MATLAB Documentation

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.