Auto Differential Equation to Simulink Block Diagram

These files give access to functions where you input your coefficients, and then a simulink block diagram will automatically be generated.

You are now following this Submission

DESCRIPTION:
These MATLAB functions ('gen_blockdiagram' and `gen_coupledsystem.m`) automatically generate a Simulink
model for simulating coupled dynamical systems of the form:
M·d²X/dt² + B·dX/dt + K·X + C = F(t)
where:
- m = Mass/Inertia matrix (n x n matrix for gen_coupled_system, singular valie for gen_blockdiagram)
- m = Damping matrix (n x n matrix for gen_coupled_system, singular valie for gen_blockdiagram)
- k = Stiffness matrix (n x n matrix for gen_coupled_system, singular valie for gen_blockdiagram)
- c = Constant vector (n x 1 matrix for gen_coupled_system, singular valie for gen_blockdiagram) [optional]
- F(t) = Input force vector (n x 1 matrix for gen_coupled_system, singular valie for gen_blockdiagram)
The generated model includes:
- Input ports for forces (F).
- Matrix operations (M⁻¹, B, K).
- Integrators for velocity/position.
- Output ports for states (X, dX/dt).
-------------------------------------------------------------------------------
REQUIREMENTS:
- MATLAB R2020a or later.
- Simulink.
- Control System Toolbox (recommended).
-------------------------------------------------------------------------------
USAGE:
1. Define system matrices (m, b, k) and optional parameters:
m = [2 0; 0 1]; % Mass matrix / value
b = [0.5 -0.2; -0.2 0.3]; % Damping matrix / value
k = [3 -1; -1 2]; % Stiffness matrix / value
2. Call function
gen_coupledsystem(M, B, K, ...
'ModelName', 'my_system', ...
'InitialConditions', [0; 0.1], ...
'Constants', [0; -9.8], ...
'InputType', 'vector');
---------------------------------------------------------------------------------
EXAMPLE:
% Define a 2-DOF system
M = diag([1.5, 2]);
B = [0.7 -0.3; -0.3 0.5];
K = [4 -2; -2 3];
% Generate model with initial displacement
gen_coupledsystem(M, B, K, ...
'ModelName', 'coupled_springs', ...
'InitialConditions', [0.1; 0]);
----------------------------------------------------------------------------------
COMMENT:
Updates are in development, for example to add step, sinusoidal and frequency inputs.

Cite As

Colin (2026). Auto Differential Equation to Simulink Block Diagram (https://www.mathworks.com/matlabcentral/fileexchange/180824-auto-differential-equation-to-simulink-block-diagram), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0