Weird issue with Simulink model

At work I’m working with a new version of the model that I’ve been working with. In the previous version of the model I haven’t had any problems at all, but now I’m running into a weird one right now.
If I open the model, do a search (find) on the model with a name, I only get one result. But if I type:
find_system('FindAll', 'on', 'Name', 'VariableName')
it return multiple instances of the name. This causes my tool to do not work properly. Has anyone seen an instance where find returns a number of instances but find_system returns a different number. All the instances of the handles I got from find_system are centered around the single instance returned from find.

 Accepted Answer

Albert Yam
Albert Yam on 28 Aug 2012
Edited: Albert Yam on 28 Aug 2012
find_system(gcs,'FindAll', 'on', 'Name', 'VariableName') %needed a sys
I've never used the edit > find, but when I used find_system, something about finding the subsystem (or root) name of what you are centered on (rather than just everything inside the subsystem). But I don't think that is your problem.
Just did a little test. [const,line,scope] all named. The find_system, found the PORT, and the signal, the edit>find, only found the signal.
Suggest, add BlockType as a parameter.
What Simulink are you using? [6.6.1 here]
EDIT:
>> sx = find_system(gcs,'FindAll', 'on', 'Name', 'sigx')
sx =
1.0e+003 *
1.8550
0.0180
>> set_param(sx(1),'null','1')
??? Error using ==> set_param
port does not have a parameter named 'null'.
>> set_param(sx(2),'null','1')
??? Error using ==> set_param
line does not have a parameter named 'null'.

7 Comments

Can you specify what you are doing? Is this correct?
handles = find_system(ModelTop,'FindAll', 'on', 'Name', 'SignalLine');
and from above n = 1:6 .. ie/
n2 = get_params(handles(2),'Parent');
n2 = ModelTop/MiddleSubsystem/ParentSubsystem
are 4,5,6 "ParentSubsystem" the same thing? [same handle number?] try
set_param(handles(4),'FontSize','40','Showname','on')
set_param(handles(5),'FontSize','50','Showname','on')
set_param(handles(6),'FontSize','60','Showname','on')
edit.. yeah ..don't save..just to see where things are
find_system has a 'SearchDepth' option, if that will help.
EDIT .. forget all that , (what I just deleted). Try this
OccurencesA = find_system('FindAll', 'on', 'Name', 'VariableName')
OccurencesB = find_system('ModelTop', 'FindAll', 'on', 'Name', 'VariableName')
you should get different things because you have another model open. Just tested this with the Simulink Library, searching for Constant. I was wondering why your line didn't have a 'sys'.
Is the VariableName coming from the logical block? Back to my first answer, the Parent of the port, is the logical block (and the logical block in the ParentSubsystem), but the Parent of the signal is the ParentSubsystem.
Is this something that is 'new' to the model? The find_system isn't wrong.
your loop
Occurences = find_system(bdroot,'FindAll', 'on', 'Name', 'VariableName')
for x = 1:Occurences(1)
should it be (or was it just a typo?)
x = 1:length(Occurences)
bdroot, is like gcs, but the root of gcs.
You have "% do random stuff depending on type", so shouldn't this filter out the port? If type == line, then do stuff, else nothing.
I'm not sure that it takes the logic block as a subsystem, just the definition of Parent (of where stuff is), is true. So the Port is part of that block, the signal is part of that subsystem.
Glad it worked out. I had that 'sys' in the first answer, should have followed up on it.
Sorry, I can't help with reference models. [No reference models, in Simulink 6.6.1, still using linked libraries]. I never used the Matlab search (edit/find).
find_system has a lookundermask, followlinks, not sure what variant is. http://www.mathworks.com/help/toolbox/simulink/slref/find_system.html
Alternatively, you can specify to "find_system(ref_block...)". You can also use "find_system(Top/Sub1/Sub2, ..)" if you want to find something somewhere specific.
Albert Yam
Albert Yam on 29 Aug 2012
Edited: Albert Yam on 29 Aug 2012
It is because you have another model or reference library open. I made a reference to the answer when I tested it with Simulink browser and Constant.
Try this as an example, open a new model, open a second new model, open the Simulink browser. Copy a block, say Cosine to the 2 open models. Don't close any model.
Now find_system('FindAll', 'on', 'Name', 'Cosine') will give 3 results, but edit/find will give one.
Edit: Meaning, if you do not define a 'sys' in the find_system, it searches all models open, not just the highlighted one.
Hm.. are you sure that your script, or some callback isn't open_system/load_system anything? I wonder if there is a way to see what systems are open/loaded. I don't know how model referencing works, I'm wondering if it has some affect if it is referenced more than once.
By 6 instances, you just mean 6 windows open right? You can close 5 of them and save, next time you open it should just be the one (or specifically choose what you want to open), just for convenience though.

Sign in to comment.

More Answers (0)

Categories

Products

Asked:

on 28 Aug 2012

Community Treasure Hunt

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

Start Hunting!