How to implement the model from Regression learner application to Simulink

Dear all
I had the problem when I want to implement the model from Regression learner applcation to simulink matlab function.
I tried to find the solutions from the others, but they are not working any more.
I used Regression Learner application-> Robust Linear ML , then export the model to workspace and save .mat in my folder
  1. Follow the answer from matlab, first I tried use saveLearnerForCoder. Then the error is [First argument must be a classification, regression, or nearest neighbor searcher model supported for code generation.]
  2. Export compant Model and when I use loadLearnerForCoder('***.mat'), the error is [Model not supported for code generation.]
  3. Then I tried to load the .mat from simulink matlab function directly. I got the error is [MATLAB class 'function_handle' found at '***' is unsupported.] However, I tested this function in Command Window and it works well.
If someone had the same problem, please let me know how to solve it.
Thank you so much for your time.
Best Regards

 Accepted Answer

SOLVED
The output model from Regression learner cannot be used directly. (even Normal mode and compact mode)
The thing you have to do it only use the mode part from the regression learner output.
Which is means
example: mdl is your output from the regression learner. The model is mdl.LinearModel
instead of use saveLearnerForCoder(mdl,***) you can use saveLearnerForCoder(mdl.LinerModel,***)
then you can follow the example from MATLAB
Hope it can help someone had the same problem as me.
Best Regards

More Answers (0)

Products

Release

R2021a

Asked:

on 9 Jul 2021

Edited:

on 13 Jul 2021

Community Treasure Hunt

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

Start Hunting!