I want to make a prediction from a trained neural network and have the prediction displayed on a display block
Show older comments
I am doing a school project using Neural networks to predict faults, I have already trained the neural network, but I am finding it difficult to use the trained model directly on simulink, using the predict blocks. I was able to use script to extract the data and make prediction and display on the workspace, but I want everything to run directly from simulink
Answers (1)
Krishna
on 28 Jan 2025
Hi Olalekan,
I understand that you are facing problems in converting your neural network into a Simulink model.
I assume that you are using the latest dlnetwork object provided in MATLAB to train your Neural Network. To know more about how to use ‘dlnetwork’ please look at this documentation on how to train simple Neural Networks using 'dlnetwork.'
If you want to convert your dlnetwork to a Simulink block you can use the function given below provided by the Layers library in Simulink,
exportNetworkToSimulink(dlnetwork)
This will generate a Simulink block which you can further use in your Simulink model. To display the output of the network you can use a scope or a display block connected as output to this model.
Please look at the below documentation to know more regarding this,
Hope this helps.
7 Comments
Olalekan
on 28 Jan 2025
Olalekan
on 29 Jan 2025
Walter Roberson
on 29 Jan 2025
exportNetworkToSimulink was introduced in R2024b, and is part of the Deep Learning toolbox.
We can assume that you are running R2024b as you did not fill out the Release category when creating the question, and surely you would have filled out the Release if you are using an older release of MATLAB.
Olalekan
on 29 Jan 2025
Walter Roberson
on 29 Jan 2025
In that case, exportNetworkToSimulink did not exist yet.
As far as I know your only option is to upgrade MATLAB versions.
Olalekan
on 30 Jan 2025
Categories
Find more on Deep Learning Toolbox 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!

