Loading Classification Model in Simulink created using MATLAB Classification Learner App
14 次查看(过去 30 天)
显示 更早的评论
I have trained a classification model using Matlab's Classification Learner App. I have exported it to the workspace and also saved it as a .mat file.
I need to embed it in a Simulink model to make predictions at every time step during simulation. I've tried multiple things like:
- Using a From File block to load the classification model from the .mat file and then using mdl.predictFcn(myInputData) to make a prediction on new data.
- Pre-loading the model in workspace and then accessing it using a Matlab Function
However, both of these methods do not work. The first method gives me an error stating that the .mat file can only have timeseries data (which it doesn't as it is a classification model) and the second method is not able to identify the pre-loaded model in the workspace.
Can someone guide me in solving this issue. Thanks
0 个评论
回答(1 个)
Drew
2023-11-3
MathWorks provides Simulink blocks for machine learning model prediction. So, you can use the native Simulink block designed for model prediction with your machine learning model. Check the "Blocks" section of the doc page https://www.mathworks.com/help/stats/code-generation.html
For example, from that doc page, here are Simulink blocks currently available for prediction with different types of ML Classifiers:
ClassificationECOC Predict Classify observations using error-correcting output codes (ECOC) classification model (Since R2023a)
ClassificationEnsemble Predict Classify observations using ensemble of decision trees (Since R2021a)
ClassificationKNN Predict Classify observations using nearest neighbor classification model (Since R2022b)
ClassificationNeuralNetwork Predict Classify observations using neural network classification model (Since R2021b)
ClassificationSVM Predict Classify observations using support vector machine (SVM) classifier for one-class and binary classification (Since R2020b)
if this answer helps you, please remember to accept the answer.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Classification Learner App 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!