How to import KNN-model structure from matlab into simulink
5 ビュー (過去 30 日間)
古いコメントを表示
All,
The problem I am facing is a move of KNN-model data structure from matlab to simulink in a loop:
In matlab TrainingData is used as input to create an KNN based-model. In simulink, at some point, I want to use this model to predict the outcome of a certain decision based on certain parameters that evolve during simulation. If the simulation ends, the outcome of the decsion is used in matlab to adjust the TrainingData and to update the KNN-model. The updated KNN-model will be used for the next simutlation.
Note that before the loop starts, the feature table exists.
Note that in matlab, the knn-model data is the outcome of the command: knnmodel = fitcknn(TrainingData, 'feature'). So i need to import this knnmodel structure into simulink.
My problem is that I do not see how to successfully import such KNN-model into the simulink model for decision making (prediction).
Is there any method to get this done?
0 件のコメント
回答 (2 件)
Aneela
2024 年 7 月 26 日
Please refer to the following MathWorks documentation to import the trained KNN model from MATLAB into Simulink:
Aneela
2024 年 8 月 18 日
Global workspace can be used facilitate the use of a Simulink model in a loop. Here is the possible workaround:
- Ensure that KNN model is trained and stored in the global workspace.
- Set up the simulink model as described in the documentation: https://www.mathworks.com/help/stats/predict-class-labels-using-classification-knn-predict-block.html#:~:text=testAccuracy%20%3D%200.9333-,Create%20Simulink%20Model,-Create%20a%20new
- Create a structure array for the input data.
- Configure the Simulink Model for input using Configuration Parameters dialog box.
- Create a MATLAB script that automates running the Simulink model in loop.
- Use the results from each iteration to adjust the model.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Statistics and Machine Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!