How to call neural network .mat file during the Simulink simulation?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/336406/image.png)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/336409/image.png)
1 comentario
Hexuan Li
el 8 de Jul. de 2021
Hi,
Do you fix this issue? because I also meet a same problem in simulink
Respuestas (1)
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!
0 comentarios
Ver también
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!