Error generating code to implement RegressionGP Model using MATLAB Function in Simulink (The input to coder.const cannot be reduced to a constant: Unsupported value.)
Show older comments
A strange problem occurs to me trying to integrate my trained RegressionGP in a Simulink Model using a MATLAB Function block, saveLearnerForCoder and loadLearnerForCoder.
I trained two GPs with the same size of predictors which is 75. I use the same script for training and optimization. The only difference are the measurements used for training. I use sequences of 25 datapoints from three sensors each.
The first GP works flawlessly in a matlab skript ans also in Simulink using a MATLAB Function block. The second GP works without problem in a MATLAB script. When I try to complie the same Simulink model with the second GP (change name of file in loadLearnerForCoder) I get the following error:
The input to coder.const cannot be reduced to a constant: Unsupported value. Function 'loadLearnerForCoder.m' (#76.1874.1895), line 41, column 68: "matFile.compactStruct" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Function call failed. Function 'MATLAB Function2' (#55.201.239), line 10, column 7: "loadLearnerForCoder('gprMdl_V106_LUT')" Launch diagnostic report.
This is the function I use in both cases:
function [prediction, upperConf, lowerConf] = gpr_predict_V101(X) %#codegen
% Copyright 2019 The MathWorks, Inc.
prediction = 0.0;
confidence = [ 0.0 0.0 ];
upperConf = 0.0;
lowerConf = 0.0;
mdl = loadLearnerForCoder('gprMdl_V101_LUT');
[prediction, ~, confidence] = predict(mdl,X);
upperConf = confidence(:,1);
lowerConf = confidence(:,2);
end
The input data is preprocess the same way for both GPs and therefore has the same size. I checked all dimensions and compared the compacStruct created for both GP through saveLearnerForCoder and couldn't finde any difference besides the GP hyperparameters and ActiveSet used.
Does anyone know where else this error could come from?
Thanks in advance!
Accepted Answer
More Answers (1)
Sriram Padavettan
on 4 Dec 2020
1 vote
Not sure if you figured it out yet, but are you using 2020A?
I had same issue and messed with it all day until I decided to try a different version and it worked - try 2020B.
1 Comment
Michelle Geilenberg
on 6 Dec 2020
Categories
Find more on Support Vector Machine Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!