how to use the parameters of neural network in simulink?
이전 댓글 표시
I trained a neural network dpending on two inputs (T and p) to predect density.
Now I have the best parameters to predect density using this code:
density = model (parameters, p, T);
Plese note that I have a simulink model with the time-step is 0.001 s, the problem is how to use this parameters of the NN in the Simulink model.
input are: p and T
output is: density
time-step is 0.001
Best regards, Ahmad
댓글 수: 3
Paul
2024년 7월 6일
Hi Ahmad,
I'm afraid I can't help you with this. Good luck.
Ahmad Al-Issa
2024년 7월 6일
Ahmad Al-Issa
2024년 7월 7일
답변 (1개)
Sam Chak
2024년 7월 7일
1 개 추천
If you want to implement a trained neural network in Simulink to predict the Desity based on two inputs (p, T), then use the Predict block.

댓글 수: 12
Ahmad Al-Issa
2024년 7월 7일
편집: Ahmad Al-Issa
2024년 7월 7일
Sam Chak
2024년 7월 7일
If the "model" is the custom function of your trained neural network, and the syntax "density = model(parameters, p, T);" is how you successfully call the neural network in MATLAB to predict the density, then I would suggest trying to utilize the MATLAB Function block within your Simulink implementation and insert the code.

The code for this block attempts to produce exactly the same results as MATLAB. However, take note that some special functions are not supported.
Ahmad Al-Issa
2024년 7월 7일
Ahmad Al-Issa
2024년 7월 7일
Ahmad Al-Issa
2024년 7월 7일
Sam Chak
2024년 7월 7일
Good then. Now put the trained dlnetwork object in the Predict block to see if it works.
Ahmad Al-Issa
2024년 7월 7일
편집: Ahmad Al-Issa
2024년 7월 7일
Sam Chak
2024년 7월 8일
Your code appears to be functioning correctly within MATLAB, and it is able to generate a plot for the density prediction. However, the "model" function you have created is not a dlnetwork class object, but rather a dlarray object. You have utilized the fullyconnect() function to construct the dlarray object.
Unfortunately, the Predict block in Simulink does not accept a dlarray object as its input.
I haven't tested this, but instead, I would suggest preloading the parameters into the MATLAB Workspace. The MATLAB Function block should then be able to access the parameters from the Workspace, without the need to load them directly within the MATLAB Function block itself.

Ahmad Al-Issa
2024년 7월 8일
Sam Chak
2024년 7월 8일
Hi Ahmad,
Thanks for your update. This error message is strange because the fullyconnect() function is supported in the MATLAB Function block according to the list below. Will need some time to figure this out.

Ahmad Al-Issa
2024년 7월 9일
카테고리
도움말 센터 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



