- Find all S-function blocks in the model using find_sustem().
- Get the position of s-function block using get_param().
- Delete the s-function block using delete_block().
- Copy the Subsystem from back-up model file using add_block() at the same position.
Is it possible to write a script to automatically replace all S-Functions in a model with their counterpart Simulink Blocks?
조회 수: 5 (최근 30일)
이전 댓글 표시
I have a huge Simulink model which is filled with loads of S-Functions, and I'm looking to write some code to automatically replace them with Simulink blocks (i.e. the original blocks that the S-Functions replaced). There are too many to go through and do it manually. I was wondering if there's some way of calling the Simulink models?
I've tried using replace_block:
open ModelName
SFuns_loc = find_system('ModelName','BlockType','S-Function');
for s = 1:max(size(char(SFuns_loc)))
replace_block('ModelName','S-Function','Mux','noprompt');
end
So I can replace them with Muxes or bus creators etc (just as an example of how I'm using the replace_block function). However, what I need is a piece of code that will do the same thing as double-clicking on each S-Function and selecting "replace block with original Simulink Model".
Thanks for your advice in advance.
Ben
댓글 수: 0
채택된 답변
TAB
2012년 9월 6일
편집: TAB
2012년 9월 6일
Try only
replace_block('ModelName','S-Function','Mux','noprompt');
It will replace all S-Function blocks in the model with Mux.
[EDITED]
I think replace_block() will not work here. You try with following steps
You can operate a loop to replace each S-function block one by one using above steps.
댓글 수: 5
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!