Replacing a neural network in a Simulink model automatically (replace_block or gensim)

6 Ansichten (letzte 30 Tage)
I need to use gensim to insert previously trained neural networks into a control system modeled in simulink. I need to automate this to test a number of neural networks. I cannot tell from the documentation of genism if it is possible to have the network generate at previously existing block location. Then, I tried to use gensim as it is described in the documentation, have it save, and then use replace_block to insert the network into my larger control system model.
I'm using a script to take my previously existing networks from a mat file, generate them, and then test them in a loop simulating the model.
I name the gensim file network and the control model is ankle_net_sim_automatic so the code I tried to follow the example in replace_block with is:
replace_block('ankle_net_sim_automatic','NARX Neural Network','Network/NARX Neural Network')
for replace_block(sys,current,new) but the block is not replaced and there is no error thrown. Add_block works but not replace_block, not sure why.
Thanks.

Antworten (1)

Abhishek Kumar Singh
Abhishek Kumar Singh am 26 Nov. 2023
Hello John,
I understand your intention to replace blocks in the Simulink model using 'replace_block'.
However, pinpointing the exact cause of the issue is challenging without the actual model. Potential reasons could include incorrect model hierarchy or block name discrepancies.
As a workaround, consider using the ‘delete_block’ and ‘add_block’ functions to achieve the replacement operation. You can find detailed information on these functions in the Simulink documentation at the following links:
  1. https://www.mathworks.com/help/simulink/slref/delete_block.html
  2. https://www.mathworks.com/help/simulink/slref/add_block.html
I trust this provides a viable workaround for the encountered issue.

Kategorien

Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by