Borrar filtros
Borrar filtros

How to initialize the class in MATALB?

1 visualización (últimos 30 días)
Adan91h
Adan91h el 5 de Jul. de 2018
Editada: per isakson el 8 de Jul. de 2018
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 comentarios
Wooshik Kim
Wooshik Kim el 5 de Jul. de 2018
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 el 6 de Jul. de 2018
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
>>

Iniciar sesión para comentar.

Respuestas (0)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by