Guy and Seth on Simulink

??? Invalid Simulink object name 4

Posted by Seth Popinchalk,

Did you ever get an error like this?

>> get_param('model_f14/Controller','TreatAsAtomicUnit')
??? Invalid Simulink object name: model_f14/Controller.

Of course. Anytime you have a typo in a call to get_param or set_param, you will get this message. This is very frustrating, especially when you look at the model, and see the block with the very same name!

The mysterious model with a Controller subsystem.

Invisible Characters!

To understand why this was happening, I had to compare the string I was using to the name of the block from using gcb (get current block).

>> s1 = 'model_f14/Controller'
s1 =
model_f14/Controller
>> s2 = gcb
s2 =
model_f14/Controller 
>> strcmp(s1,s2)
ans =
     0

The string from gcb looks the same, but then I noticed the size of the signals in the workspace.

The workspace show the two variables, s1 and s2 are lenths 20 and 21 respectively.

The block has a trailing white-space character! Where did this space come from? The space was probably an accidental keystroke while naming the subsystem. This can happen to anyone, so how could you detect it in your model?

Model Guidelines and Model Advisor

Most teams doing Model-Based Design for production work eventually implement modeling guidelines/standards. Modeling standards make it possible for teams to make components that work well together and look like they were made by the same team. Often, modeling standards include rules about what blocks to use, what settings to use, how to architect the model, how to layout the diagram and naming conventions.

The MathWorks Automotive Advisory Board assembled modeling guidelines for control algorithm modeling and many were implemented as Model Advisor checks (as part of Simulink Verification and Validation). The group of checks I need are the Naming Convention checks under the Modeling Standards for MAAB task.

Model Advisor MAAB control algorithm modeling standards, checks for Naming Conventions.

When I selected the Check subsystem names and clicked Run This Check, I got the report you see above. Notice it flagged the model_f14/Controller block as containing an incorrect character. Incorrect characters are those not in the list of allowed characters:

a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9 _

There are a few standards related to Naming Conventions:

For a moderate to large model, you can imagine the time this type of model check would save you.

What are your modeling standards? Do you run the Model Advisor to check that models conform to the standard? Leave a comment here with your thoughts.

4 CommentsOldest to Newest

I hate the “Invalid Simulink object name” error, the last time that happened to me was yesterday, there was one space character in the block name, other errors I get often are caused by stuff like this
get_param(‘model_f14\Controller’,'TreatAsAtomicUnit’)
or
get_param(‘model_f14/controller’,'TreatAsAtomicUnit’)

I don’t follow any model standard yet and also don’t use the Model Advisor but it would save me a lot of time!

@Paulo Silva – I used to have the very same problem with forward and back slashes. Somehow, I think I just got the right slash type habit.

1) The shortest overview of best practices that I’ve found: ‘MathWorks Automotive Advisory Board Checks’ in Simulink Validation & Verification Reference, http://www.mathworks.com/help/pdf_doc/slvnv/slvnv_ref.pdf or http://www.mathworks.com/help/toolbox/slvnv/ref/brlhc3t.html

2) Good tool for replacing all blanks in block names with underscores and other sorts of global replaces, http://www.mathworks.com/matlabcentral/fileexchange/26424-simulink-model-string-replacement

Add A Comment

What is 2 + 3?

Preview: hide

These postings are the author's and don't necessarily represent the opinions of MathWorks.