필터 지우기
필터 지우기

How to use fitrgp in Simulink?

조회 수: 6 (최근 30일)
Adan91h
Adan91h 2018년 7월 4일
편집: Adan91h 2018년 7월 4일
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개)

카테고리

Help CenterFile Exchange에서 Gaussian Process Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by