Filter löschen
Filter löschen

How to initialize the class in MATALB?

1 Ansicht (letzte 30 Tage)
Adan91h
Adan91h am 5 Jul. 2018
Bearbeitet: per isakson am 8 Jul. 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 Kommentare
Wooshik Kim
Wooshik Kim am 5 Jul. 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 am 6 Jul. 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
>>

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by