How to use prediction model from Classification Learner App in Simulink? ("Dot notation not allowed")
이전 댓글 표시
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?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Naming Conventions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!