필터 지우기
필터 지우기

How to generate code of Machine Learning functions for real-time application?

조회 수: 5 (최근 30일)
Lorenzo Brunelli
Lorenzo Brunelli 2023년 9월 26일
답변: Drew 2023년 9월 26일
Good morning,
I integrated a machine learning model developed with the classification learner application by matlab into an existing simulink model to make predictions taking some inputs calculated by the simulink model itself. I managed to do that using the "interpreted matlab function" block and calling a matlab function from it which includes the code to make prediction with the trained classification model. This allowed to compile and run the simulink model, but the issue is that the "interpreted matlab function" block does not support code generation, which is needed for my application since I want to build the model for the MicroAutoBox II (so with a system target file rti1401.tlc). So I replaced it with a simple matlab function block (which should be suitable for code generation) and then generated a .mex file of the function previously called in the "interpreted matlab function" block which includes the instructions to make prediction with the classification model. The Simulink model is still compiling and running, but if I try to build the model I get the following error:
"The extrinsic function 'FaultClass_CodeGen_mex' is not available for standalone code generation. It must be eliminated for stand-alone code to be generated. It could not be eliminated because its outputs appear to influence the calling function. Fix this error by not using 'FaultClass_CodeGen_mex' or by ensuring that its outputs are unused."
where FaultClass_CodeGen_mex is the mex file mentioned above.
I've tried different approaches suggested by other users on the web, but I could not be able to solve the problem. Is there an alternative way to do that? Or maybe, could it be an issue related to a too old version of the software?
Thank you for the support.

답변 (1개)

Drew
Drew 2023년 9월 26일
Native Simulink blocks for model prediction have been developed, with more being added release by release. These support code generation. Below is an image from the doc page listed above, showing a list of available classification predict blocks at this time, and the release in which they were added:
If this answer helps you, please remember to accept the answer.

카테고리

Help CenterFile Exchange에서 Multicore Processor Targets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by