hilite_system inside a library block

I am trying to use hilite_system to hilite a simulink block, however that block lies inside a library block. If I open the model and make the call to hilite_system I get an error that the object name is invalid. However if I navigate throught the model into the library block and try again it works. It would appear that the problem is that the library block is not fully "loaded"? Is there a way around this?

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 3월 18일

2 개 추천

It is true. When you open the model, Simulink doesn't automatically load all the customized library blocks.
To make your script work, I suggest adding a line after you open the model.
Open_system(Model); find_system(Model,'FollowLinks','On');

댓글 수: 5

Kaustubha Govind
Kaustubha Govind 2011년 3월 18일
+1
Jeremy Johnson
Jeremy Johnson 2011년 3월 21일
That seems to work when I only have one linked library, but if I have a library within a library it still fails. I am thinking of writing a function that would break apart the path and call find_system on each block leading up to the block that I actually care about. If I do that manually from the command prompt it works. Is there a more efficient way?
Kaustubha Govind
Kaustubha Govind 2011년 3월 21일
Try:
find_system(Model,'FollowLinks','On','LookUnderMasks','all');
Does this fix the issue?
Jeremy Johnson
Jeremy Johnson 2011년 3월 21일
I already tried that, it didn't work either.
Jeremy Johnson
Jeremy Johnson 2011년 3월 21일
I wrote code to parse the path and call find_system on each block "leading" to the desired block before calling hilite_system and it is working great. Thanks for the help.

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

추가 답변 (1개)

Fangjun Jiang
Fangjun Jiang 2011년 3월 22일

0 개 추천

So you have a model with nested library links. I have a model with three layers of nested library links. The find_system() seems to work so I don't know why it didn't work in your case. I am using R2007b.
Try a different approach, run the command libinfo(Model) after opening the model. It works too in my case. If it works for you, it might be easier than parsing the block path.

댓글 수: 1

Jeremy Johnson
Jeremy Johnson 2011년 3월 22일
libinfo is definitely simpler and does work, but parsing the string and calling find_system multiple times is definitely faster. Most likely because libinfo is loading every library that the model references not just the ones required for the current query. Thanks for the info, I will definitely file that one away in my "bag of tricks."

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

카테고리

도움말 센터File Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by