replace_block and load_system

조회 수: 3 (최근 30일)
Lucas
Lucas 2012년 6월 8일
I have 2 questions, first being:
1. Can replace_block replace blocks with custom made blocks? I'm having some trouble with that so I don't know if it's supported or not. Can you tell replace block to only replace blocks on the top level or in a subsystem?
2. Can you run load_system and tell it not to save the changes you made? I want to use replace_block, run my model and exit leaving the model in its original state.

채택된 답변

Kaustubha Govind
Kaustubha Govind 2012년 6월 8일
Yes, you should be able to replace blocks using replace_block with custom blocks as well. You will need to specify the full path of the library for custom blocks. Also, you might need to make sure that the custom library is loaded using load_library.
To have replace_block replace only inside a subsystem, you need to specify the path of the subsystem as the first argument (instead of the name of the top-level model).
To have it replace only blocks in the top level, use the 'SearchDepth' argument as follows:
>> replace_block('vdp', 'SearchDepth', 1, 'BlockType', 'Gain', 'Integrator')
If you are loading/opening a model, you also need to close it using close_system. You can tell close_system to not save changes by using the saveflag argument:
>> close_system('vdp', 0)
  댓글 수: 1
Kaustubha Govind
Kaustubha Govind 2012년 6월 8일
No, you just need to make sure that model is on the MATLAB path. Then, run load_system('External_In_Out_Blocks'). Then, if that library has a block with the name (let's say) 'My Custom Block', the path you need to use for the new_blk argument is 'External_In_Out_Blocks/My Custom Block'.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by