How to call neural network .mat file during the Simulink simulation?

5 visualizaciones (últimos 30 días)
Young Jae Choi
Young Jae Choi el 24 de Jul. de 2020
Comentada: Hexuan Li el 8 de Jul. de 2021
Hi,
I have made an neural network model by using 'fitnet' function in Matlab and saved it as 'ANN2.mat'
In my simulink model, I would like to use this nn model to predict an output. (the simulink model is expressed below)
What I have done is put a 'm-function' and script is like this:
function y = fcn(Tset, Tsa, Tra, Qair, dT_w)
load ANN2
input = [Tset, Tsa, Tra, Qair, dT_w]'
output = net(input)
y = output;
But an error occurs:
As I don't know much about matlab & simulink, it is hard for me to understand the error and how to solve.
What is wrong with my script?
Is there any method to import my neural network model as .m or .mat file and execute it?
Because I'm trying to train nn model with new data which is generated by every simulink timestep, I want to avoid using blocks supporting from simulink.
Thank you very much in advance for your time.

Respuestas (1)

Harsha Priya Daggubati
Harsha Priya Daggubati el 27 de Jul. de 2020
Hi,
I guess the error might be because of using 'net'. Since you saved the network as ANN2 you need to use ANN2(input) instead of net.
You can also look at the following link for a list of options available to use Simulink to train a neural network:
Hope this helps!

Categorías

Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by