matlabadaboost

(matlab) how to load adaboost model so that coder compatible?


I save my adaboot model as .mat file. I use this to load the model:

load('adaboost_23.mat')

But matlab coder cannot generate C/C++ code. So I change to:

coder.load('adaboost_23.mat')

Still not working:

error message

How should I do it? Data type is ClassificationEnsemble.


Solution

  • Now I know. According to matlab guidance, you have to compact model first.

    mdl = load('train_model.mat');
    saveLearnerForCoder(mdl, 'compacted_model');
    

    And load model.

    cpt = loadLearnerForCoder('compacted_model');
    

    After that, Coder will hard code your model and you will get your model in cpp file.