Seth on Simulink

June 26th, 2009

My Mental Model of a Model

When you are new to something, it always helps to get a mental picture of how that something works.  Since I learned Simulink over 10 years ago, I have developed my own mental model of Simulink models.  Today I want to present a mental model for the three basic components in Simulink block diagrams, ports, blocks and signals.

Something Familiar

A good mental model is something to which you are already familiar.  I like to compare Simulink diagrams to programs written in a procedural language like MATLAB or C.  My favorite is MATLAB, so that is usually how I think.

Ports

Ports are the input and output arguments for the function.

Blocks

When I think about blocks, I think of them as algorithmic components of the programs.  A block like the Gain or Product is a function that operates on inputs and produces an output.

Signals

Signal lines pass the value output from one block to the next block.  I think of signal lines as the variables in a program.

A Simulink block diagram and corresponding M-code to illustrate my mental model.

Generating Code

With my intuition in hand, I read the generated code so I can compare and refine my mental model.  The result is here:

The generated code from the model.  Pretty close to the mental model.

In this case, I made a couple tweaks to the code generation settings for readability and interface. 

What do you think?

How does your mental model of a block diagram compare to mine?  Leave a comment here and share it with me.

2 Responses to “My Mental Model of a Model”

  1. M.tamilselvan replied on :
    this piece of snippet is short and crisp,need to post more mental model strutures in depth possible with optimization issuses.
    
  2. Jarrod Rivituso replied on :

    “I think of signal lines as the variables in a program.”

    I say the exact same thing every time I teach our Simulink courses :)

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Seth Popinchalk is an Application Engineer for The MathWorks. He writes here about Simulink and other MathWorks tools used in Model-Based Design.
  • Guy: @Shahin - The Simulink Control Design toolbox offers functionalities similar to the one provided by the new PID...
  • Shahin Moghimi: Hi, I have the R2008a version, and am wondering if there is such an automatic tool in my version as...
  • ponmani: Respected sir, i am working simulink for the past 6 months. i am trying to place my control algorithm...
  • Seth: @Aleksandar - If you build a Simulink model into an executable using Real-Time Workshop, you will only be able...
  • Aleksandar: Seth, thank you very much! I have additional question. Is it possible to alter Simulink model built into...
  • Seth: I am not sure of your implementation of the D flip flop, and I am not sure how it is causing an algebraic loop...
  • esayas: nice work !
  • Seth: @Checker - Due to the high volume of reservation requests our career fair team had to pre-screen profiles based...
  • Checker: I filled it out couple of days back and got an emial saying that the no. of people they can handle is...
  • Seth: @Jonathan - in the case of the Buffer block, you can not use the result calculated in one part of the model to...

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