MATLAB: How to predict with a classifier inside a MATLAB function block

simulinkStatistics and Machine Learning Toolbox

I have sucessfully created a classification object (e.g. ClassificationSVM). Now I want to use it inside Simulink, i.e.
in a MATLAB function block to predict given specific inputs. How can I achieve this?

Best Answer

This is possible employing saveCompactModel, loadCompactModel and a separate .m file.
In the attachments, there is a dummy example.
Note that some restrictions apply when it comes to generating code from such models: