Borrar filtros
Borrar filtros

How to use fitrgp in Simulink?

6 visualizaciones (últimos 30 días)
Adan91h
Adan91h el 4 de Jul. de 2018
Editada: Adan91h el 4 de Jul. de 2018
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!

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by