Introduction
Welcome to the twelfth article in our comprehensive MATLAB course series. In the previous article, we introduced Simulink and walked through the basics of creating and simulating a simple model. Now it’s time to dive deeper into the rich ecosystem of pre-built blocks that make Simulink such a powerful tool for dynamic system simulation.
If you think of Simulink as a workshop, then the block libraries are your toolbox. Just as a master carpenter needs to know their chisels from their planes, a Simulink user needs to know their Integrators from their Transfer Functions, their Mux blocks from their Demux blocks. The Simulink Library Browser contains thousands of pre-built blocks, organized into logical libraries by domain and function. Knowing your way around these libraries—and understanding how and when to use each block—is essential for building effective models.
In this article, we’re going to take a comprehensive tour of Simulink’s most commonly used block libraries. We’ll explore the Continuous library (for modeling continuous-time dynamics), the Math Operations library (for mathematical computations), the Signal Routing library (for managing signal flow), the Discrete library (for discrete-time systems), the Logic and Bit Operations library (for logical and bitwise operations), and several others. For each block type, we’ll discuss what it does, when to use it, and how to configure its parameters.
But we won’t just be cataloging blocks like a reference manual. Instead, we’ll weave our discussion with practical examples, modeling tips, and deep analysis of Simulink’s inner workings. We’ll learn about signal attributes and data types, about sample times and how they propagate through a model, about masking blocks to create reusable, parameterized components. And we’ll tie it all together by building a complete PID controller in Simulink—a quintessential engineering task that showcases many of the blocks we’ve learned.
By the end of this article, you’ll have a solid understanding of Simulink’s block libraries and be able to build sophisticated models by connecting the right blocks together. You’ll understand not just the “how” of block usage, but also the “why”—the engineering principles and Simulink architecture that underlie the block-diagram paradigm. Let’s open the Library Browser and get started.
Library Browser Organization: Navigating the Treasure Trove
Before we dive into specific block libraries, let’s take a moment to understand how the Simulink Library Browser is organized. As we discussed in the previous article, you can open the Library Browser by clicking the “Library Browser” button in the Simulink toolstrip, by pressing Ctrl+Shift+L, or by typing slLibraryBrowser in the MATLAB Command Window.
The Library Browser Interface
The Library Browser is organized as a tree structure on the left side, with block icons and descriptions on the right side. The top-level nodes in the tree are libraries—collections of related blocks. When you expand a library, you see sublibraries (further organization) and/or individual blocks.
The Simulink core libraries (those that come with base Simulink) are organized as follows:
1. Commonly Used Blocks
This isn’t really a library in the strict sense—it’s a curated selection of the most frequently used blocks from across Simulink’s libraries. Think of it as a “greatest hits” collection. It includes blocks like:
- In1, Out1: Input and output ports (for subsystems and models)
- Constant: A constant value
- Gain: Multiply by a constant
- Sum: Add or subtract signals
- Product: Multiply or divide signals
- Integrator: Integrate a signal (continuous-time)
- Discrete-Time Integrator: Integrate a signal (discrete-time)
- Unit Delay: Delay a signal by one sample
- Step: Step input
- Ramp: Ramp input
- Sine Wave: Sine wave generator
- Signal Generator: Arbitrary waveform generator
- Scope: View signals
- To Workspace: Log signals to MATLAB
- Subsystem: Create a subsystem
The “Commonly Used Blocks” library is a great place to start when you’re new to Simulink. As you become more experienced, you’ll likely find yourself going directly to the more specialized libraries.
2. Sources
The Sources library contains blocks that generate signals. These are the starting points of your signal flow—the blocks that provide inputs to your system. Sources include:
- Constant: Outputs a constant value.
- Signal Generator: Generates various waveforms (sine, square, sawtooth, random).
- Step: Generates a step function (value changes at a specified time).
- Ramp: Generates a ramp (linearly increasing/decreasing signal).
- Sine Wave: Generates a sine wave.
- Pulse Generator: Generates pulses (useful for digital systems).
- Chirp Signal: Generates a frequency-swept cosine (useful for frequency response analysis).
- Clock: Outputs the current simulation time.
- Digital Clock: Outputs the current simulation time at a specified sample interval.
- From Workspace: Reads data from a MATLAB workspace variable.
- From File: Reads data from a file.
- Random Number: Generates normally distributed random numbers.
- Uniform Random Number: Generates uniformly distributed random numbers.
We’ll explore many of these blocks in detail later in this article.
3. Sinks
The Sinks library contains blocks that consume signals—they’re the endpoints of your signal flow. Sinks don’t produce outputs (in the traditional sense); they display, log, or terminate signals. Common sinks include:
- Scope: Displays signals in an oscilloscope-like interface.
- To Workspace: Writes signal data to a MATLAB workspace variable.
- To File: Writes signal data to a file.
- Display: Shows the current value of a signal.
- Floating Scope: A Scope that can display any signal (not just connected signals).
- Terminator: Terminates a signal (useful for unused outputs).
- Stop Simulation: Stops the simulation when a condition is met.
- Out1: Output port (for subsystems and models).
4. Continuous
The Continuous library contains blocks for modeling continuous-time dynamic systems. These blocks use continuous-time integration and differentiation. Key blocks include:
- Integrator: Integrates the input signal.
- Integrator Limited: Integrates with limits on the output.
- Derivative: Computes the derivative of the input.
- Transfer Function: Implements a transfer function.
- State-Space: Implements a state-space model.
- Zero-Pole: Implements a zero-pole-gain transfer function.
- Transport Delay: Delays the input by a fixed amount of time.
- Variable Time Delay: Delays the input by a variable amount of time.
- PID Controller: Implements a PID controller.
We’ll spend considerable time on the Continuous library, as it’s central to modeling physical systems.
5. Discrete
The Discrete library contains blocks for discrete-time systems. These blocks operate at specific sample times. Key blocks include:
- Unit Delay: Delays the input by one sample.
- Delay: Delays the input by a specified number of samples.
- Discrete-Time Integrator: Integrates the input (discrete approximation).
- Discrete Transfer Function: Implements a discrete-time transfer function.
- Discrete Filter: Implements a discrete-time filter.
- Discrete State-Space: Implements a discrete-time state-space model.
- Zero-Order Hold: Holds the input constant for one sample period.
- First-Order Hold: Holds the input using first-order extrapolation.
6. Math Operations
The Math Operations library, as the name suggests, contains blocks for mathematical computations. These are the workhorses of many Simulink models. Blocks include:
- Add: Adds inputs.
- Subtract: Subtracts inputs.
- Sum: Adds or subtracts inputs (more general than Add/Subtract).
- Product: Multiplies or divides inputs.
- Divide: Divides inputs.
- Gain: Multiplies by a constant.
- Slider Gain: Multiplies by a variable gain (adjustable via a slider).
- Matrix Gain: Multiplies by a matrix.
- Math Function: Applies a mathematical function (exp, log, sqrt, etc.).
- Trigonometric Function: Applies a trigonometric function (sin, cos, etc.).
- MinMax: Outputs the minimum or maximum of inputs.
- Abs: Outputs the absolute value.
- Sign: Outputs the sign of the input.
- Floor, Ceil, Round: Rounding functions.
7. Signal Routing
The Signal Routing library contains blocks for managing the flow of signals—combining, splitting, selecting, and switching signals. Key blocks include:
- Mux: Multiplexes (combines) several signals into a vector signal.
- Demux: Demultiplexes (splits) a vector signal into its components.
- Switch: Selects one of two inputs based on a condition.
- Multiport Switch: Selects one of several inputs based on a control input.
- Merge: Merges several signals into one (for use with conditionally executed subsystems).
- Select: Selects elements from a vector or matrix signal.
- Bus Creator: Creates a bus signal (a structured signal with named elements).
- Bus Selector: Selects elements from a bus signal.
- Goto, From: Non-graphically connect signals (use sparingly—they can make models hard to read).
8. Logic and Bit Operations
The Logic and Bit Operations library contains blocks for logical and bitwise operations. These are essential for modeling digital logic and decision-making in your models. Blocks include:
- Relational Operator: Compares two inputs (>, <, ==, etc.).
- Logical Operator: Performs logical operations (AND, OR, NOT, etc.).
- Bitwise Operator: Performs bitwise operations (AND, OR, XOR, etc.).
- Shift Arithmetic: Shifts bits (left, right, arithmetic, logical).
- Combinatorial Logic: Implements a truth table.
- Compare to Constant: Compares a signal to a constant.
- Interval Test: Tests if a signal is in a specified interval.
9. Signal Attributes
The Signal Attributes library contains blocks for specifying and modifying signal properties. These blocks are often “invisible” (they don’t change the signal value), but they’re crucial for ensuring your model simulates correctly and efficiently. Blocks include:
- Data Type Conversion: Converts a signal from one data type to another.
- Data Type Duplicate: Ensures all inputs have the same data type.
- Data Type Propagation: Forces signal data type based on specified rules.
- Signal Specification: Specifies signal attributes (data type, dimensions, etc.).
- Width: Outputs the width of a vector signal.
- Probe: Outputs signal attributes (width, dimensions, etc.) as signals.
10. User-Defined Functions
The User-Defined Functions library contains blocks that let you incorporate custom code into your Simulink model. This is where MATLAB Function blocks and S-Function blocks live. Blocks include:
- MATLAB Function: Lets you write MATLAB code inside a Simulink block.
- S-Function: Lets you incorporate C/C++/Fortran/MATLAB code as a block.
- S-Function Builder: A graphical interface for creating S-Functions.
- Level-2 MATLAB S-Function: A more flexible (but more complex) way to create S-Functions in MATLAB.
- Interpreted MATLAB Function: Calls a MATLAB function (slower but easier than MATLAB Function block).
- MATLAB System: Incorporates a System object (from MATLAB) as a block.
11. Ports & Subsystems
The Ports & Subsystems library contains blocks for model hierarchy and input/output. We discussed these in the previous article, but as a refresher:
- Subsystem: Creates a subsystem.
- In1, Out1: Input and output ports.
- Enable: Adds an enable port to a subsystem.
- Trigger: Adds a trigger port to a subsystem.
- Model: References another model.
- Atomic Subsystem: A subsystem that executes as a unit.
- Enabled Subsystem: A subsystem that executes when enabled.
- Triggered Subsystem: A subsystem that executes when triggered.
- Function-Call Subsystem: A subsystem that executes when called by a function-call signal.
Searching for Blocks
With thousands of blocks available, you won’t always remember exactly where a block lives in the library hierarchy. That’s where the Library Browser’s search function comes in. Type a keyword in the search box at the top of the browser, and it will show all blocks whose names or descriptions match your query.
For example, if you type “integrator”, the search will show the Integrator block from the Continuous library, the Discrete-Time Integrator from the Discrete library, and any other blocks with “integrator” in their name or description.
The search function is your friend. Use it liberally.



