difficulties with add_block

조회 수: 4 (최근 30일)
Tomas Iesmantas
Tomas Iesmantas 2011년 3월 12일
댓글: Shiv Nileshkumar Matliwala 2022년 11월 29일
Hello,
I know that for simulink blocks to be programmatically put into model one needs to load simulink system (load_system('simulink')), but it won't work for simhydraulics, or for simscape blocks. I think that solution should be like for simulink blocks, but I don't know the syntax: load_system('???????'). I just get error: ??? There is no block named 'nesl_utility/Simulink-PS Converter' Does any body know the solution?

채택된 답변

Guy Rouleau
Guy Rouleau 2011년 3월 12일
Not sure what is going wrong for you. The following works for me:
load_system('nesl_utility')
add_block(sprintf('nesl_utility/Simulink-PS\nConverter'),'myMdl/blk1')
If it does not work for you, let us know the error message.
  댓글 수: 2
Tomas Iesmantas
Tomas Iesmantas 2011년 3월 13일
thanks, this is exactly what I needed (i.e.'nesl_utility' part).
Shiv Nileshkumar Matliwala
Shiv Nileshkumar Matliwala 2022년 11월 29일
suppose, I have the code as below,
file_name = 'New_model'
new_system(file_name)
model = 'Model1.slx'
load_system(model)
%now here, this 'Model.slx' has one block called 'Model'
%so now I want to add that block into my new system 'New_model'
%so I will write as below,
add_block('model/Model','file_name/Model')
%but when I write like this, It is showing some error.
So, is there any way I can add block using file names stored in some variable ?
like above, 'New_model' is stored in variable file_name. So, now I want to use only file_name to add block.
Any idea how to do it ?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by