I exported a prediction model "PredictionModel" from the Classification Learner App. I want to use this model in Simulink - either in a Matlab Function block or in a Matlab Function box in Stateflow.
In the command line window it works perfectly like this:
>> Maxtemp=6
Maxtemp =
>> Precipitation=3
Precipitation =
>> T=table(Maxtemp,Precipitation,'VariableNames',{'modeTmax','modePrecip'})
T =
1×2 table
modeTmax modePrecip
________ __________
6 3
>> y=PredictionModel.predictFcn(T)
y =
So this is one of the code varieties I tried for a Matlab Function box in Stateflow (without the % sign that seems needed for formatting in this forum):
function pred=Prediction(Tmax,Precip)
coder.extrinsic('table');
coder.extrinsic('PredictionModel');
coder.extrinsic('PredictionModel.predictFcn');
T=table(Tmax,Precip,'VariableNames',{'modeTmax','modePrecip'});
pred=PredictionModel.predictFcn(T);
end
but apparently I cannot call predictFcn this way, because I'm getting an error message "Dot notation on function call return value is not allowed." Using 'pred=predictFcn(T)'instead; doesn't help either (-> "Undefined function or variable 'predictFcn'").
The same problems when trying to use the prediction model in a Matlab Function block in Simulink.
Is there a workaround for this?