MATLAB Answers

How to Import RegressionGP model to Simulink

1 view (last 30 days)
KE FANG
KE FANG on 9 Jul 2018
Answered: Shota Kato on 3 Jan 2020
Hi, I have trained a GPS model and it's in the base workspace (1x1 RegressionGP). How can I import it to a Simulink model? Is there a way to easily populate a Simulink Block of it? Thanks.

  0 Comments

Sign in to comment.

Answers (1)

Shota Kato
Shota Kato on 3 Jan 2020
Hi, I had the same problem.
You can solve the problem by using "saveCompactModel" and "loadCompactModel".
Given the trained model, you can sace the model ("Mdl") to a file named "Model.mat".
Mdl = fitrgp(X, Y);
saveCompactModel(Mdl, 'Model');
In a Simulink model, for example, you can use MATLAB Function and load the model as follow;
function y = compute_y(x)
Mdl = loadCompactModel('Model');
y = predict(Mdl, x);
end

  0 Comments

Sign in to comment.

Sign in to answer this question.

Products