How to initialize the class in MATALB?

1 次查看(过去 30 天)
I want to use 'fitrgp' function in Matlab Simulink.
fitrgp returns a GPmodel and its type of class is 'RegressionGP'.
for example:
y=fitrgp(rand(100,2),rand(100,1));
class(y)
ans =
'RegressionGP'
i used the matlab function block in MATLAB simulink and used the following code
function y = fcn()
coder.extrinsic('fitrgp');
y=fitrgp(rand(100,2),rand(100,1));
it gives me following error and recommends me to preinitialize the output.
Function output 'y' cannot be an mxArray in this context. Consider
preinitializing the output variable with a known type
how can i preinitialize this 'RegressionGP' class so that i can use 'fitrgp' command in MATLAB Simulink?
  2 个评论
Wooshik Kim
Wooshik Kim 2018-7-5
you can try initializing y
what is the output of fitrgp?
if it is an array, initialize y with an array of the same size
Adan91h
Adan91h 2018-7-6
Hi Kim,
No it is not an array. The output is a ''class'' with type 'RegressionGP'.
see the below response
>> y=fitrgp(rand(100,2),rand(100,1));
>> y
y =
RegressionGP
ResponseName: 'Y'
CategoricalPredictors: []
ResponseTransform: 'none'
NumObservations: 100
KernelFunction: 'SquaredExponential'
KernelInformation: [1×1 struct]
BasisFunction: 'Constant'
Beta: 0.5041
Sigma: 0.2552
PredictorLocation: []
PredictorScale: []
Alpha: [100×1 double]
ActiveSetVectors: [100×2 double]
PredictMethod: 'Exact'
ActiveSetSize: 100
FitMethod: 'Exact'
ActiveSetMethod: 'Random'
IsActiveSetVector: [100×1 logical]
LogLikelihood: -11.8893
ActiveSetHistory: []
BCDInformation: []
Properties, Methods
>>

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by