How to use fitrgp in Simulink?
조회 수: 2 (최근 30일)
이전 댓글 표시
Can anyone tell me how to use fitrgp command in MATLAB Simulink?
i tried the following code in simulink within MATLAB function block but i'm receiving error.
if true
% code
myinput = [rand(100,1) rand(100,1)];
myoutput= rand(100,1);
coder.extrinsic('fitrgp');
% opts = statset('fitrgp');
% opts.TolFun = 1e-2;
sigma0 = 1e-5;
sigmaF0 = 1e-5;
d = 2;
sigmaM0 = 1e-2*ones(d,1);
% GPMdl = rand(100,1);
GPMdl = fitrgp(myinput,myoutput,'Basis','constant','FitMethod','exact',...
'PredictMethod','exact','KernelFunction','ardsquaredexponential',...
'Optimizer','QuasiNewton',...
'KernelParameters',[sigmaM0;sigmaF0],'Sigma',sigma0,'Standardize',1);
end
Error message is '' Function output 'GPMdl' cannot be an mxArray in this context. Consider preinitializing the output variable with a known type.''
i tried to define the GPMdl initially like
if true
% code
myinput = [rand(100,1) rand(100,1)];
myoutput= rand(100,1);
coder.extrinsic('iddata');
GPMdl=iddata(myinput,myoutput,1);
coder.extrinsic('fitrgp');
% opts = statset('fitrgp');
% opts.TolFun = 1e-2;
sigma0 = 1e-5;
sigmaF0 = 1e-5;
d = 2;
sigmaM0 = 1e-2*ones(d,1);
% GPMdl = rand(100,1);
GPMdl = fitrgp(myinput,myoutput,'Basis','constant','FitMethod','exact',...
'PredictMethod','exact','KernelFunction','ardsquaredexponential',...
'Optimizer','QuasiNewton',...
'KernelParameters',[sigmaM0;sigmaF0],'Sigma',sigma0,'Standardize',1);
end
but still i receive the above error.
when i predefine GPMdl like GPMdl = rand(100,1) which is wrong because fitrgp output is 1x1 RegressionGP class / metaclass.
if true
% code
myinput = [rand(100,1) rand(100,1)];
myoutput= rand(100,1);
coder.extrinsic('fitrgp');
% opts = statset('fitrgp');
% opts.TolFun = 1e-2;
sigma0 = 1e-5;
sigmaF0 = 1e-5;
d = 2;
sigmaM0 = 1e-2*ones(d,1);
GPMdl = rand(100,1);
GPMdl = fitrgp(myinput,myoutput,'Basis','constant','FitMethod','exact',...
'PredictMethod','exact','KernelFunction','ardsquaredexponential',...
'Optimizer','QuasiNewton',...
'KernelParameters',[sigmaM0;sigmaF0],'Sigma',sigma0,'Standardize',1);
end
then i receive the following error
MATLAB expression 'fitrgp' is not numeric.
Block GPMdl (#1160) While executing: State During Action
thanks in advance!
댓글 수: 0
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!