How to use prediction model from Classification Learner App in Simulink? ("Dot notation not allowed")
Show older comments
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 =
6
>> Precipitation=3
Precipitation =
3
>> T=table(Maxtemp,Precipitation,'VariableNames',{'modeTmax','modePrecip'})
T =
1×2 table
modeTmax modePrecip
________ __________
6 3
>> y=PredictionModel.predictFcn(T)
y =
2
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?
1 Comment
Wilfred
on 20 Nov 2017
Accepted Answer
More Answers (0)
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!