I want to generate code using MATLAB Coder for a simple GP model as such:
function [Mean] = CmpcPredict(X,ID)GP_ID = ID; GP_CmpMdl = loadCompactModel(GP_ID); %this does not compile
% GP_CmpMdl = loadCompactModel('16122391'); %this does compile
[Mean] = predict(GP_CmpMdl,X);end
It seems like if the ID is specified within the CmpcPredict function, the code generation is completed correctly.
However, if the ID is specified outside of the CmpcPredict function, the code generation returns the following error:
??? Non-constant expression or empty matrix. This expression must be constant
because its value determines the size or class of some expression.
Best Answer