- https://www.mathworks.com/help/simulink/slref/delete_block.html
- https://www.mathworks.com/help/simulink/slref/add_block.html
Replacing a neural network in a Simulink model automatically (replace_block or gensim)
6 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Abhishek Kumar Singh
2023-11-26
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:
I trust this provides a viable workaround for the encountered issue.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!