You are on page 1of 716

Dynamic System Simulation for MATLAB

Modeling
Simulation
Implementation

Using Simulink
Version 4

03-5978-5411

03-5978-5440

2 15 6

http://www.cybernet.co.jp/products/matlab
infomatlab@cybernet.co.jp
techmatlab@cybernet.co.jp

Web

Using Simulink
COPYRIGHT 1990 - 2000 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied only
under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior
written consent from The MathWorks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by or for the federal
government of the United States. By accepting delivery of the Program, the government hereby agrees that this software qualifies as "commercial" computer software within the meaning of FAR Part 12.212, DFARS Part 227.7202-1, DFARS Part
227.7202-3, DFARS Part 252.227-7013, and DFARS Part 252.227-7014. The terms and conditions of The MathWorks, Inc.
Software License Agreement shall pertain to the governments use and disclosure of the Program and Documentation, and
shall supersede any conflicting contractual terms or conditions. If this license fails to meet the governments minimum needs
or is inconsistent in any respect with federal procurement law, the government agrees to return the Program and Documentation, unused, to MathWorks.
MATLAB, Simulink, Stateflow, Handle Graphics, and Real-Time Workshop are registered trademarks, and Target Language
Compiler is a trademark of The MathWorks, Inc.
Other product or brand names are trademarks or registered trademarks of their respective holders.

Printing History:

November 1990
December 1996
January 1999
November 2000
January 2001

First printing
Revised for Simulink 2
Revised for Simulink 3 (Release 11)
Revised for Simulink 4 (Release 12)


Getting Started

1
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6

2
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-2
2-3
2-4
2-4
2-5

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15
Simulink Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15

Simulink

3
Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-4
3-4
3-5
3-6
3-6
3-6
3-7
3-7
3-8

. . . . . . . . . . . . . . . . . . . . . . 3-9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
. . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
Atomic . . . . . . . . . . . . . . . . . . . . 3-13
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-23
3-23
3-23
3-23
3-24
3-24
3-26
3-27
3-28

4
Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ii

4-2
4-3
4-3
4-4

Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-10
4-10
4-10
4-11
4-13
4-13
4-14
4-14
4-15
4-17
4-17
4-18
4-18
4-19
4-20
4-20
4-21
4-21
4-22

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-24
4-24
4-25
4-25
4-26
4-27
4-28
4-28

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-30
4-30
4-32
4-33
4-34

iii

. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .

4-35
4-36
4-37
4-38
4-38
4-39
4-39
4-40
4-40
4-41

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-44
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Simulink . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Boolean . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-45
4-45
4-46
4-46
4-47
4-47
4-47
4-48
4-49
4-49
4-49

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
Simulink . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-51
4-51
4-52
4-53
4-53
4-54
4-54
4-56
4-61

. . . . . . . . . . . . . . . . . . . . . . . . . . . 4-63
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-66
Subsystem . . . . . . . . . 4-66

iv

. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-67
4-68
4-68
4-69
4-70

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .

4-71
4-71
4-71
4-72

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-76
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .

4-77
4-77
4-77
4-78
4-78
4-79
4-79
4-80
4-80
4-80
4-81
4-81
4-82
4-82
4-83
4-85

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-87
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-87
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-88
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-90
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-91
Print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-91
Print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-92

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-93
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-94
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-95
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-95
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-100
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-106
4-106
4-109
4-113
4-114

Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-116

5
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
. . . . . . . . . . . . . . . . 5-3
. . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Simulation Diagnostics . . . . . . . . . . . . . . . . . . . .

5-4
5-4
5-4
5-4
5-6

Simulation Parameters . . . . . . . . . . . . . . . . . . . . . . 5-8


Solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8
Workspace I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18
Diagnostics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29
. . . . . . . . . . . . . . . . . . . . . . . . . 5-34
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-34
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-35

vi

. . . . . . . . . . . . . . . . .
sim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
set_param . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
sim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
simplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
simset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
simget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5-36
5-36
5-36
5-38
5-41
5-43
5-47

6
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
To Workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6-2
6-2
6-2
6-3

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7
linfun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9
trim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-12

7
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-3
7-4
7-6
7-6

Mask Editor: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8

vii

Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
. . . . . . . 7-13
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14
Icon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-17
7-17
7-19
7-20
7-21
7-22

Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Mask Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Block Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Mask Help Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-26
7-26
7-26
7-27

Self-Modifying . . . . . . . . . . . . . . . . . . . . . . . . . . 7-28
. . . . . . . . . . . . . . . . . 7-29
. . . . . . . . . . . . . . . 7-29
. . . . . . . . . . . . . . . . . . . . . . . 7-30

8
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Enabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
Enabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
Enabled . . . . . . . . . . . . . . . 8-5
Triggered . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8
Triggered . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-9
Function-Call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-10

viii

Triggered . . . . . . . . . . . . 8-10
Triggered and Enabled . . . . . . . . . . . . . . . . . . . . . . . . . . .
Triggered and Enabled . . . . . . . . . . . . . . . . . . . .
Triggered and Enabled . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .

8-12
8-12
8-13
8-13

9
. . . . . . . . . . . . . . . . . . . . . . . . 9-2
Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3
Abs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-11
Algebraic Constraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-13
Backlash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-15
Band-Limited White Noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-19
Bitwise Logical Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-21
Bus Selector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-25
Chirp Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-27
Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-29
Combinatorial Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-31
Complex to Magnitude-Angle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-34
Complex to Real-Imag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-35
Configurable Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-36
Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-40
Coulomb and Viscous Friction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-42
Data Store Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-44
Data Store Read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-46
Data Store Write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-47
Data Type Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-49
Dead Zone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-51
Demux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-53
Derivative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-58
Digital Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-60
Direct Look-Up Table (n-D) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-61
Discrete Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-67

ix

Discrete Pulse Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-69


Discrete State-Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-72
Discrete-Time Integrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-74
Discrete Transfer Fcn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-82
Discrete Zero-Pole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-84
Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-86
Dot Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-89
Enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-91
Fcn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-93
First-Order Hold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-95
From . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-97
From File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-99
From Workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-102
Function-Call Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-106
Gain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-108
Goto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-111
Goto Tag Visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-114
Ground . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-115
Hit Crossing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-116
IC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-118
Inport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-120
Integrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-124
Logical Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-130
Look-Up Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-132
Look-Up Table (2-D) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-135
Look-Up Table (n-D) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-138
Magnitude-Angle to Complex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-143
Manual Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-145
Math Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-146
MATLAB Fcn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-148
Matrix Gain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-150
Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-152
Merge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-154
MinMax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-157
Model Info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-159
Multiport Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-162
Mux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-164
Outport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-166
Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-170
Probe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-173

Pulse Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Quantizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Ramp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Random Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Rate Limiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Real-Imag to Complex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Relational Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Relay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Repeating Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Reshape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Rounding Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Saturation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Selector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
S-Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Sign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Signal Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Sine Wave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Slider Gain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
State-Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Stop Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terminator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
To File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
To Workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Transfer Fcn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Transport Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Trigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Trigonometric Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Uniform Random Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Unit Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Variable Transport Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
XY Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Zero-Order Hold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Zero-Pole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

9-175
9-177
9-179
9-181
9-183
9-185
9-187
9-189
9-191
9-193
9-195
9-196
9-198
9-208
9-212
9-214
9-215
9-218
9-221
9-223
9-225
9-227
9-228
9-232
9-235
9-237
9-238
9-240
9-243
9-246
9-248
9-250
9-252
9-254
9-256
9-259
9-260
9-262
9-263

xi

10
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
. . . . . . . . . . . . . . . . . . . . . . . 10-3
Simulink . . . . . . . . . . . . . . . . . 10-3
add_block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-4
add_line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-5
bdclose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-6
bdroot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-7
close_system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-8
delete_block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-10
delete_line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-11
find_system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-12
gcb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-17
gcbh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-18
gcs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-19
get_param . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20
new_system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-22
open_system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-23
replace_block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-24
save_system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-26
set_param . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-27
simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-29

Simulink

11
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-3
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-4
. . . . . . . . . . . . . 11-6
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-6
MATLAB . . . . . . . . . . . . . . . . . . . . . . 11-6
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-7

xii

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-8
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-8
. . . . . . . . . . . . . . . . . . . . . 11-9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .

11-11
11-12
11-14
11-14
11-14
11-14

. . . . . . . . . . . . . . . . . . . . . . . .
I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11-16
11-16
11-18
11-18
11-19

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-20
. . . . . . . . . . . . . . . . . . . . . . . . . . 11-20
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-20
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ashow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
atrace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
bafter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
break . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
bshow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
clear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
continue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
disp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ishow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
minor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
nanbreak . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
probe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
quit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
run . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11-24
11-27
11-28
11-29
11-30
11-31
11-32
11-33
11-34
11-35
11-36
11-37
11-38
11-39
11-40
11-41
11-42

xiii

slist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
tbreak . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
undisp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
untrace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xbreak . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
zcbreak . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
zclist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11-43
11-44
11-45
11-46
11-47
11-48
11-49
11-50
11-51
11-52
11-53
11-54
11-55

Performance Tools

12
Simulink Performance Tools . . . . . . . . . . . . . . . . . . . . . . . . 12-2
Simulink Accelerator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-3
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-3
Simulink Accelerator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-4
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-5
Accelerator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-6
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-7
Simulink Accelerator Simulink Debugger . . . . . . . . . . . . . . 12-8
Simulink Accelerator . . . . . . . . . . . 12-9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-10
Simulink Accelerator Build . . . . . . . . . . . 12-10
Simulink Accelerator S- . . . . . 12-11
Model Differencing Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-13
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-15
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-15
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-17
. . . . . . . . . . . . . . . . . . . . . . 12-17

xiv

. . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-19
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-20
Model Coverage Tool( ) . . . . . . . . . . . . . . . . .
Model Coverage Tool . . . . . . . . . . . . . . .
Model Coverage Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
Model Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

12-23
12-23
12-23
12-24
12-26
12-29
12-31

A
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-7
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-10
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-26

B
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
BlockDefaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
AnnotationDefaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

B-2
B-3
B-3
B-3
B-3

xv

xvi

1
Getting Started
. . . . . . . . . . . . . . . . . . . . . . . . . . 1-2

Simulink . . . . . . . . . . . . . . . . . . . . . . . 1-2
. . . . . . . . . . . . . . . . . . . . 1-3

. . . . . . . . . . . . . . . . . . . . . . 1-6

1 Getting Started

Simulink ! Simulink

Simulink

MATLAB

Simulink

Simulink
-

Simulink
Simulink

Simulink
Simulink
Simulink

Simulink

(GUI)
( )

1-2

Simulink

Writing S-Functions

Simulink
MATLAB

"what if (
)"
MATLAB

MATLAB
MATLAB
MATLAB
Simulink

Simulink

Simulink 2

Simulink

1-3

1 Getting Started

Simulink 3 Simulink
Simulink

5
Simulink

6
Simulink MATLAB
7

9 Simulink

10 MATLAB M

11 Simulink Simulink
Simulink
12 Performance Tools Simulink
Simulink

A
10
get_param set_param
B

1-4

Simulink Known Software and


Documentation Problems

1-5

1 Getting Started

The MathWorks Simulink

CD

The MathWorks Web www.mathworks.com "products"


The Math Works Web
www.mathworks.com Simulink
www.mathworks.com/products/connections/

MATLAB
Simulink

1-6

-Analysis and Synthesis


Toolbox

CDMA Reference Blockset

IS-95A
Simulink

Communications Blockset

Simulink

Communications Toolbox

MATLAB

Control System Toolbox

Dials & Gauges Blockset

Simulink

DSP Blockset

Simulink

Fixed-Point Blockset

Simulink

Frequency Domain System


Identification Toolbox

Motorola DSP Developers


Kit

Motorola Suite56TM DSP


MEX- S-

Nonlinear Control Design


(NCD) Blockset

Simulink

Power System Blockset

Simulink

Real-Time Windows Target

PC Simulink

Real-Time Workshop

.Simulink Stateflow

Real-Time Workshop Ada


Coder

Ada 95
Simulink

1-7

1 Getting Started

1-8

Real-Time Workshop
Production Coder

Simulink

Requirements Management
Interface

( )

Robust Control Toolbox

Signal Processing Toolbox

Simulink Performance Tools

Simulink Report Generator

MATLAB, Simulink, Stateflow

Stateflow

Stateflow Coder

Stateflow
C

System Identification
Toolbox

Developers Kit for


Texas Instruments DSP

Texas Instruments (TI) C6701


(C6701 EVM) Simulink

xPC Target

Simulink I/O
Real-Time Workshop
xPC Target
PC
xPC Target DSP

hardware-in-the-loop

1-9

1 Getting Started

1-10

. .
. . . .

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

2-2
2-3
2-4
2-4
2-5

. . . . . . . . . . . . . . . . . . . . . 2-6
Simulink . . . . . . . . . . . . . . . . . . . . . .2-15
Simulink Preferences . . . . . . . . . . . . . . . . . . . . 2-15

Simulink

1 MATLAB MATLAB

2 MATLAB thermo

Simulink

3 Thermo Plots Scope

Scope Indoor vs. Outdoor Temp Heat Cost ($) 2

4 Simulation Start

( Windows Simulink
Start )

2-2

Indoor vs. Outdoor Temp Scope


Heat Cost ($) Scope
5 Simulation Stop

( Pause )
2-4

6 File Close

( ) 70
15 50

Subsystem
5
ThermostatHouse Temp Convert 3 (2 1
)
House
House

House subsystem

2-3

Thermostat

Thermostat subsystem

Fahrenheit to Celsius conversion (F2C)

Heat Cost ($) Thermo Plots Scope


Indoor Temp Scope

Scope

Scope 9-198
Scope
( )Set Point Constant

80
(Avg Outdoor Temp )

Daily Temp Variation Sine Wave


Amplitude

2-4

Start
5-4


4-66

7

thermo Subsystem

Scope
Scope 9-198 Scope

Simulink

1 MATLAB simulink3 Simulink

Demos

2 Demos MATLAB Demo Window

Simulink

2-5

MATLAB simulink
Microsoft Windows Simulink

2-6

UNIX Simulink

UNIX Simulink
File New Model Windows
New Model

New Model

2-7

Simulink

Simulink

Sources (Sine Wave )


Sinks (Scope )
Continuous (the Integrator )
Signals & System (Mux )
(Windows ) Sources
Sources (UNIX Windows) Sine Wave

Sine Wave
Sources
Simulink Sources
Sources Sources
Sine Wave Sine Wave

2-8

Simulink

Sources

Sine Wave

Sine Wave
Simulink Sine Wave

Sources Sine Wave


Simulink Sources Sources
(Windows Simulink
Simulink
Open Library )Simulink Sources

2-9

Sine Wave

Sources Sine Wave

2-10

Sine Wave (>)


Mux 2 >

Input port

Output port

Sine Wave Mux


Sine Wave
( )

Mux
Mux

2-11

( 2-6
)1
Sine Wave Integrator
Sine Wave Mux

1
Sine Wave Mux

2 Ctrl

Integrator Integrator

2-12

3 Simulink Integrator

Scope Scope
10
Simulation Simulation Parameters
Stop time
10.0( )

Stop time parameter

OK Simulation Parameters
Simulink

2-13

Simulation Start Scope

Simulation Parameters
Simulation Stop
File Save

Simulink MATLAB File Exit MATLAB


(Microsoft Windows )Quit MATLAB (UNIX
MATLAB quit
Simulink MATLAB Simulink

2-14

Simulink

Simulink
MATLAB Preferences Simulink
Preferences
Simulink File Preferences

Simulink Preferences
Preferences
Simulink

Window reuse

(4-68
)

Model Browser

2-15

(4-100
)

Display

(4-38
)

Callback tracing
Simulink
(4-71
)

Simulink Fonts

Solver
(5-8 Solver
)

Workspace
(5-18
Workspace I/O )

Diagnostics
(5-25
Diagnostics )

2-16

3
Simulink
Simulink

. . . . . . . . . . . . . . . . . . . . . . . 3-2

. . . . . . . . . . . . . . 3-3

. . . . . . .
. . . . . . . . .
. . . . . . . . . . .
. . . . . . .
. . . .

. . . . . . .
. . . . .
. . . . . . . . . . .
. . . . . . .
. . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

3-3
3-3
3-4
3-4
3-5
3-6
3-6
3-6
3-7
3-7
3-8

. . . . . . .
. . . . . . . . .
. . . . . . . .
. . .
Atomic
. . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

. . 3-9
. . 3-9
. 3-10
. 3-10
. 3-11
. 3-13
. 3-13
. 3-14
. 3-18

. . . . . . . . . .3-23

. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . .
. . . . . . .

. . . . . . . .
. . . . . . . . . . . . .
. . . .

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

3-23
3-23
3-23
3-24
3-24
3-26
3-27
3-28

3 Simulink

Simulink
Simulink

Simulink

Simulink 2
Simulink

(3-3
)Simulink
Simulink (
3-9 )

3-2

Simulink
Simulink point-and-click

( 4 )Simulink

( 9
)

(continuous )
(discrete )

The MathWorks web site MATLAB Based Books

u
(input)

x
(states)

y
(output)

3-3

3 Simulink

Simulink Integrator Integrator

Integrator
Integrator
Simulink Memory
Memory
Memory
Simulink Gain Gain
Gain

Sum Product
(Sum Product )

Simulink

fo
fu,

3-4

xd

y = f o ( t, x, u )

Output function

= f u ( t, x, u )

Update function

k+1

x' c = f d ( t, x, u )
where

x =

Derivative function

xc
xdk

t x u y
xd xc
Simulink

Simulink Gain

MATLAB
Simulink

Gain

Simulink

Simulink
Gain

529

3-5

3 Simulink

Simulink

Constant Simulink Continuous


Discrete Pulse Generator
Discrete
Simulink Gain

Simulink
( ) ( )
( ) ( )3-28

Simulink
Simulink Subsystem
Simulink

( 8
. )

Simulink

Simulink
Subsystem wrap Simulink

3-6

M- MEX-
(Writing S-Functions )S-
S- Simulink
S-function S-function Subsystem
Subsystem
S-function

Simulink signal
Simulink ( 8 16 32
) ( ) (1 2 )

Simulink MATLAB
int8, double boolean(4-45 )
Simulink 2
Simulink
Simulink.Parameter
Simulink.Signal
Simulink int32
Simulink Simulink
Simulink
Simulink
Simulink

Simulink MATALB
Simulink

3-7

3 Simulink

Simulink

Simulink (ODE)

3-8

Simulink Simulation
Start

Simulink
1
2

( 3-13 Atomic
)
3

( 3-11 )
4 (

Simulink
source

3-9

3 Simulink

Simulink

( 3-13
) ( 3-23
)
(3-14 )

Simulink

Simulink

Simulink
1 ( 3-11

)
Simulink
Simulink

Simulink

Simulink
Simulink

3-10

Simulink
3-14

Simulink 1 4

Simulink
1

Simulink

Direct Feedthrough
Simulink

direct feedthrough
nondirect-feedthrough
direct-feedthrough Gain, Product, Sum
nondirect-feedthrough Integrator (
)Constant ( )Memory (
)

3-11

3 Simulink

Simulink

direct-feedthrough

direct-feedthrough

Nondirect-feedthrough direct-feedthrough

nondirect-feedthrough
Simulink
nondirect-feedthrough
nondirect-feedthrough
direct-feedthrough

Simulink direct-feedthrough

Simulink
direct-feedthrough deadlock condition

Simulink
direct-feedthrough

3-18

Simulink ( 4-20
)

3-12

Atomic
virtual atomic Simulink
Simulink
atomic
atomic
atomic

Simulink
Simulink
Simulink
Simulink
2

(
)

3-13

3 Simulink

Simulink

Simulink

3-14

Simulink
Simulink

Simulink
Simulink

Simulink
( )
Simulink
Simulink
Simulink
Simulink

Simulink Saturation
Saturation





Simulink

Hit Crossing
3-17

Saturation

zcSignal = UpperLimit - u u

3-15

3 Simulink

rising

falling

either rising falling

Saturation either

Simulink
1

" " 2

not
detected

detected

513 Error
Tolerances

Refine (5-16 )

3-16

( )

Simulation Parameters
Diagnostics Disable zero crossing detection
5-31

Abs

1 :

Backlash

2 : 1 1

Dead Zone

2 : 1 (
) 1 (
)

Hit Crossing

1 :
Simulation Parameters
Disable zero crossing detection

Integrator

3
1 1
1

3-17

3 Simulink

(Continued)

MinMax

1 :

Relay

1 :

Relational
Operator

1 :

Saturation

2 : 1
1

Sign

1 :

Step

1 :

Subsystem

1
1

Switch

1 :

Simulink

Elementary Math
Gain
Integrator
Product
D State-Space
Sum
Transfer Fcn
Zero-Pole

3-18

9
.

(
3-20 )

Sum z
u z ( z = u - z)
z = u/2

z1, z2

Algebraic Constraint (Algebraic Constraint )


Algebraic Constraint
F(z) z

3-19

3 Simulink

F(z) = 0
z 1 F

1 F(z) = z - (u - z)

z2 + z1 1 = 0
z2 z1 1 = 0
F(z) = 0

(DAE)

Simulink
( )

F(z) = 0 Simulink
1
z

1 (
) IC
1
Algebraic Constraint

IC Algebraic Constraint

2


( 8-8
Triggered ).

3-20

Simulink

z=1+u

3-21

3 Simulink

u z

u2

z=z+1

3-22

Simulink ( )

Sample time

Sample time [Ts,offset]


Ts offset

t = n * Ts + offset

n offset

discrete 1

3-23

3 Simulink

DTF1 Discrete Transfer Fcn Sample time [1 0.1]


0.1 DTF2 Discrete Transfer Fcn
Sample time 0.7
( 5-3 Running a Simulation from the Command
Line ) stairs
[t,x,y] = sim(multirate, 3);
stairs(t,y)

y(2)

y(1)

0.1 DTF1 t = 0.1


DTF1 y(1)

3-24

Simulink

Simulink


0.25 0.5
0.25 0.5
0.75 0.25

(
)

0.00

0.25

0.50

0.75

1.00

1.25

1.50

1.00

1.25

1.50

Fixed-Step Solver

0.00

0.25

0.50

0.75

Variable-Step Solver

3-25

3 Simulink

(Real-Time Workshop )Simulink

Gain Ts Discrete Filter

Gain
Gain
Simulink

Simulink

Continuous ( Integrator, Derivative, Transfer Fcn )

Constant ( Constant)
Discrete ( Zero-Order Hold, Unit Delay, Discrete Transfer Fcn )


Integrator Gain
Zero-Order Hold Gain
Zero-Order Hold

( )

Simulink source

3-26

Simulink Signal Generator Discrete-Time


Integrator Signal Generator Gain
Discrete-Time Integrator

Simulink Format Sample Time Colors

Discrete-Time Integrator

Discrete-Time Integrator Integrator


Edit Update diagram
Signal Generator Gain

Simulink Constant
Constant

Constant Gain

3-27

3 Simulink

Simulink

Format Sample Time Colors

Simulink (5-29
) " "

2 1
2

Runge-Kutta
ode23 ode45
ode15s
ode113

3-28

Simulink

. . . . . . . . . . . . . . . . . . . . . . 4-2

. . . . . . . . . . . . . . . . . . . . . 4-8

. . . . . . . . . . . . . . . . . . . . . . . . .4-10

. . . . . . . . . . . . . . . . . . . . . .4-24

. . . . . . . . . . . . . . . . . . . . . . . .4-30

. . . . . . . . . . . . . . . . . . . . . . . . . . .4-44
. . . . . . . . . . . . . . . . . . . . .4-45
. . . . . . . . . . . . . . . . . .4-51
. . . . . . . . . . . . . .4-63
. . . . . . . . . . . . . . . . . . . . .4-66
. . . . . . . . . . . . . . . .4-71
. . . . . . . . . . . . . . . . . . . . .4-76

. . . . . . . . . . . . . . . . . . . . . . . .4-77

. . . . . . . . . . . . . . . . . . . . .4-87

. . . . . . . . . . . . . . . . . . . . . . .4-90

. . . . . . . . . . . . . . . . . . . . .4-91
. . . . . . . . . . . . . . . . . . .4-95
. . . . . . . . . . . . . . . . . . 4-106
Simulink . . . . . . . . . . . . . . . . . 4-116

Simulink
Simulink MATLAB
MATLAB Simulink
2
MATLAB Simulink

MATLAB simulink
Microsoft Windows Simulink Simulink

Simulink

4-2

Simulink

UNIX Simulink Simulink

Simulink Simulink

Windows Simulink
Simulink

(Windows )
New File
New Model
2

477

(Windows) Open
Simulink File Open

MATLAB .mdl )

4-3

Simulink
Simulink

Simulink
Simulink (Microsoft Windows )
Simulink (Windows )
MATLAB

Simulink
Simulink

Windows Simulink

Simulink
Windows Simulink Simulink

Simulink View Toolbar

Toolbar

Simulink

4-4

Simulink

Simulink

Simulink View Toolbar

MATLAB
MATLAB
MATLAB
5 , 6

Edit Undo 101






Edit Redo Undo

Simulink
Simulink
( )
MATLAB Figure
Handle Graphics
Simulink
/

4-5

Windows Simulink

Simulink View
Status Bar / /

Simulink Simulink

View Zoom In ( r

View Zoom Out ( v

Select View Fit System to View(


) (
)
ViewNormal (
100%)

Simulink

4-6

Simulink

Simulink

View Fit System to View( )

4-7

1
( )

1
1 1
4
" "
Sine Wave

Shift
Shift

4-8

Edit
Select All
466

4-9

Simulink

Microsoft Windows Simulink

Simulink View Block Data Tips(


)

Simulink 2

Simulink

4-1:

4-10

Bus Selector

Data Store Memory

Demux

Enable Port

From

4-1: (Continued)

Goto

Goto Tag Visibility

Ground

Inport

Outport

Mux

Outport

(
) Simulink
( )

Selector

Subsystem

Treat as Atomic Unit

Terminator

Test Point

Trigger Port

Simulink

1
2

4-11

Simulink Library Browser


4-83
Simulink sum,mux,demux,bus selector Simulink

(
)

Edit Copy/Paste

1
2 Edit Copy
3
4 Edit Paste

Simulink

Linear Gain
Gain
Gain
Simulink ( Gain1Gain2)
418 .

Simulink 5

4-12

MATLAB

set_param(<model name>,showgrid,on)

set_param(<model name>,gridspacing,<number of pixels>)

20

set_param(<model name>,gridspacing,20)

2 <model name>
gcs
CopyCutPaste ( )

Shift

Edit Undo

1
Simulink

48
2

Ctrl

4-13

Simulink
( A-7 )
4-15
1
( A-10
)

Edit
( ) BLOCK Parameters
BLOCK Constat
Parameters
Library

Edit

9

Simulink set_param
10-27 set_param
set_param
MATLAB

4-14

Simulink
(4-54
)

Edit Edit BLOCK Parameters


BLOCK
Constat Properties

Block Properties

Description( )

4-15

Priority( )

4-20

Tag( )

Open function( )
MATLAB

Attributes format string( )


AttributesFormatString
A
AttributesFormatString

%< >
%<priority> Simulink

(\n)

pri=%<priority>\ngain=%<Gain>

Gain

Simulink
N/S( ) Simulink
"???"

4-16

1 Delete
Backspace Edit Clear Cut
Cut
Delete Backspace
Clear

Edit Undo

Format

Flip Block 180


Rotate Block 90
Rotate Block Flip Block
Simulink

2
3

3
Rotate

Down

Rotate

Left
to
Right

Right
to
Left

Flip

Up

Rotate
1

1
2
3

Rotate
3

4-17

Signal Generator

Microsoft WindowsUNIX

4-18

Simulink

Format
Font Set Font

Edit Undo


Format Flip Name

417

Format

Hide Name
Hide Name Show Name
Show Name

Simulink

4-19

Block PropertiesAttributes format string


( 4-15
)
tset_param (10-27 set_param )
AttributesFormatString

Shift

set_param(b,Priority,n)

b n ( 0
)2
3
Block Properties Priority
( 4-15
)
Simulink Simulink
(3-11
)
Simulink
Simulink
(5-25 Diagnostics
)

4-20

Simulink Format
Execution order( )

1
2 2

Format Show Drop Shadow

Hide Drop Shadow


Subsystem

4-21

Simulink

4-2:

MuxDemux )

Format Sample Time


Colors
Simulink
Edit Update Diagram
Sample Time Colors

4-22

Mux Demux

Demux
Mux
Demux ( )

4-23

430

2
3 2

4 Simulink

Simulink
Shift

4-24

1
Product Scope To Workspace

1
2 Ctrl
3

Ctrl
Ctrl

Simulink

Simulink
Shift

4-25

4-26

2
Simulink

3 Shift

5 Shift

4-27

Simulink

4-28

3 Simulink

4-29

Simulink

Simulink

Simulink

Simulink
Simulink

Simulink 1 2 1
(1-D) 1 (
) 1 (1-D) 2
(2-D) 1 2-D ( )
2 Simulink
1-D 2-D
1 1
1 2 (2-D) 1 1 2 (2-D)
Simulink

9
, .

4-34

Simulink double
Simulink MATLAB
4-45

4-30

Simulink
4-37

Mux
(4-10
)

Mux (
) 1
1
1

Simulink (signal propagation)

Simulink

s4 Gain G1 s4
Gain G1 s1 Simulink

Simulink Show Propagated Signals (4-41


)

4-31


Mux
1
Simulink

Simulink

( 9-53 Demux
) Mux,Demux

Signal Bus

4-32

1
Simulink
Simulink Format Signal
Dimentions Simulink

Simulink

445

( )

1 1 1-D 2-D

Mux Demux

Simulink

(2-D)
M x N M
N

4-33

source

Source
source source
Constant Sine Wave (Simulink source
9-1, Sources Library )source
Interpret Vector Parameters as 1-D
off( )
Interpret Vector Parameters as
1-D on N 1
1 N
N
source Interpret Vector Parameters as 1-D
Constant
Constant value
Constant value Interpret Vector Parameters as 1-D

4-34

Constant value

Interpret vector
parameters as 1-D

2-D

off

2-D

2-D

on

1-D

1 N

off

1 N

1 N

on

N 1

off

N 1

N 1

on

Constant value

Interpret vector
parameters as 1-D

M N

off

M N

M N

on

M N

Simulink source

Source
(

Simulink
( 4-36
)

2

Simulink
( 4-37
)

4-35

Nx1 1xN
Simulink N
MATLAB
1xN Nx1

Simulink

Simulink
1 1
1 1
Simulink
1
1 Simulink 1 1


527

Simulink

9 Simulink

Simulink

4-36

Constant1 Constant

[3 3 3]

Simulink
Simulink
Gain

Simulink

Simulink

(Gain)
3

Simulink

MATLAB

Constant

4-37


Real-Imag to Complex

Simulink
9 , .

Simulink
Simulink

Simulink

Edit Update Diagram


Simulink

Simulink

Wide nonscalar lines

Signal dimensions

Port data types

Simulink Format
( )

4-38


Name (4-41
)
name
p = get_param(gcb, PortHandles)
l = get_param(p.Inport, Line)
set_param(l, Name, s9)

(<)

Ctrl

4-39

1
Shift Delete
Backspace
Format
Font Set Font

(<) (
)
Simulink

Show Propagated Signals

(4-41 )

Simulink Signal Properties


Simulink Edit Signal
Properties

4-40

Signal Properties

Signal Name

Show propagated signals


4-41

off

on

s1 s2 s3
s1
s1<s2,s3>

all

s1 s2 s3
s3 s4 s5
s1
s1<s2,s4,s5>

Description

Document link
MATLAB
(
)
web([file:/// which(foo_signal.html)])

MATLAB
Web foo_signal.html

Displayable (Test Point)

4-42

2 Real-Time Workshop

RTW storage class

Real-Time Workshop Users Guide

RTW storage type qualifier


Real-Time
Workshop Users Guide

4-43

Microsoft Windows UNIX

Shift key Delete


Backspace

Format Font

( )
Format Text Alignment
Text Alignment 1
( Center)

4-44

MATLAB

MATLAB MATLAB
Simulink Simulink

Simulink The
MathWorks Real-Time Workshop

Simulink

Simulink (double) Simulink

( 4-48
)

Simulink
Simulink MATLAB "
" MATLAB
MATLAB

4-45

Simulink " "


MATLAB

double

single

int8

uint8

int16

16

uint16

16

int32

32

uint32

32

Simulink boolean (1 0)
uint8

Simulink double
boolean

9

double

type(value)

4-46

type value

single(1.0)

1.0

int8(2)

8 2

int32(3+2i)

32

inport From Workspace


MATLAB
Constant

Data Type Conversion

Simulink Format
Port Data Types Simulink
Ctrl-D

Simulink

Simulink
Simulink

4-47

typecasting ( )

4-49

Constant

Simulink

4-49

Constant
Data Type Conversion

Mux Demux

( ) boolean
double
Solver double
double

4-48

Boolean
Simulink boolean double

double
Simulink Simulation Parameters
Advanced Boolean logic signals
boolean (5-29
)

Simulink

Simulink Data
Type Conversion ( 9-49
Data Type Conversion )

Simulink
( )

Simulink

uint8( 8 )

4-49

int32( 32 )

Simulink
Simulink
(uint8)
uint8 (0 255) 255
Simulink

( 256)Simulink
out-of-range

Simulink
( 5-27 )

Simulink
(2)
2.0 Simulink

int32 float double


int32
Simulink

4-50

Simulink Simulink
( )
Simulink

Simulink

Simulink
2 Simulink.Parameter Simulink.Signal

Simulink
Simulink Simulink
Simulink Simulink.Parameter Simulink.Signal Simulink

MATLAB M-

PackageName.ClassName

4-51

PackageName.ClassName

Simulink
Simulink.Parameter

2
A B C
MATLAB
M-

Simulink
Parameter Signal


A.B a.b

Simulink Simulink
MATLAB
4-61
Simulink
MATLAB

h = package.class(arg1, arg2, ...argn);

h MATLAB package class


arg1, arg2, ... argn
(Simulink.Parameter Simulink.Signal
)Simulink.Parameter
MATLAB
hGain = Simulink.Parameter;

Simulink.Parameter

4-52

Simulink
(4-61 Simulink )
MATLAB
4-58

MATLAB M-

hObject.property

hObject property

hGain = Simulink.Parameter;
hGain.Value = 5;

Simulink
5 gain.RTWInfo.StorageClass gain
StorageClass

hObject.method

method(hObject)

hObject Simulink

get
MATLAB
copy

4-53

MAT- MATLAB save


MATLAB
MATLAB load
MATLAB

Simulink

Simulink

Simulink
Simulink

Simulink.Parameter

1 MATLAB Simulink

2 Value

(4-56 )
( Real-Time Workshop )

4 set_param

4-56

4-54

(5-29
)
RTWInfo.StorageClass Auto
( )
gain.RTWInfo.StorageClass = SimulinkGlobal;
RTWInfo.StorageClass Auto
(5-32
)

Simulink

Simulink.Signal

1
2
(4-56

) (

Real-Time Workshop )

Simulink
4-56

4-55

(
)
RTWInfo.StorageClass auto

Signal
Properties (4-41
)
Simulink

Simulink

MAT- (4-54
)
PreLoadFcn
load data_objects.mat

set_param(gcs, PreLoadFcn, load data_objects);

MATLAB load data_objects

M-

M-

4-56

Simulink (matlabroot/toolbox/simulink/simdemos)
UserDefined

MATLAB

@PackageName
PackageName

4-57

@ClassName
ClassName
schema.m M
schema.m ClassName.m
ClassName

@package_name
MATLAB @PackageName
schema.m
M- schema.m MATLAB
function schema ()
%
schema.package('PackageName);

PackageName

1 @ClassName

ClassName

2
3

MATLAB schema

create_user_class (4-60
create_user_class )

4-58

function schema()
%
%
userClass = UserDefined.Parameter;
%
deriveFromClass = Simulink.Parameter;
%
%
create_user_enumtype(colors, {red, green, blue});
%
addProperties = {
UserMATLABArray1, MATLAB array, []; ...
UserMATLABArray2, MATLAB array, ; ...
UserDouble,
double,
0; ...
UserInt32,
int32,
0; ...
UserOnOff,
on/off,
off; ...
UserString,
string,
; ...
UserColorEnum, colors,
red; ...
};
% ( )
create_user_class(userClass, deriveFromClass, addProperties);

Simulink
M-

Parameter Simulink Parameter.m M-


Parameter M-

function h = Parameter()
%
%
h = UserDefined.Parameter;

4-59

function h = Parameter(varargin)
%
%
h = UserDefined.Parameter;
% ( )
if nargin == 1
% 1 "Value"
h.Value = varargin{1};
end

(4-60 create_user_class
) n 3 n
( angle) ( double)

Simulink.Signal Simulink.Parameter

Simulink Simulink Simulink

create_user_class.
(schema.m)
3

( UserDefined.Parameter)
( Simulink.Parameter)

4-60

(4-60
)
create_user_enumtype.

create_user_enumtype 2


colors

create_user_enumtype(colors, {red, green, blue});


findpackage.
h_SimulinkPackage = findpackage(Simulink);
findclass.
h_SimulinkParameter = findclass(h_SimulinkPackage, Parameter);
findproperty.
h_ParamValue = findparameter(h_SimulinkParameter, Value);

Simulink
Simulink MATLAB

Simulink Tools Data explorer


MATLAB slexplr

4-61

2 MATLAB

Filter (
Simulink )

value
1

4-62

LMB CMB RMB

4-3:

Microsoft Windows

UNIX

LMB

LMB

Shift + LMB

Shift + LMB; CMB

Tab

Tab

Shift + Tab

Shift + Tab

Ctrl + LMB

Ctrl + LMB

RMB

RMB

LMB

LMB

Shift +

Shift +

CMB

Enter

Return

Esc

Esc

4-63

4-4:

Microsoft Windows

UNIX

LMB

LMB

Shift + LMB

Shift + LMB; CMB

Ctrl +
RMB

Ctrl +
RMB +

Shift +

Shift +
CMB +

Shift +

Shift +
CMB +

4-5:

4-64

Microsoft Windows

UNIX

Ctrl +

Ctrl +

4-5: (Continued)

Microsoft Windows

UNIX

Shift +
Delete

Shift +
Delete

4-6:

Microsoft Windows

UNIX

Ctrl +

Ctrl +

Shift + ,
Delete

Shift + +

Delete

4-65


1
Subsystem 1

2
Subsystem

Subsystem
Subsystem

1 Signals & Systems Subsystem


2 Subsystem

Simulink (4-68
)

3 Subsystem

Inport Outport
Sum
Inport Outport

4-66

Select All

48

Sum
Unit Delay

2 Edit Create Subsystem Simulink

Subsystem Create Subsystem


( Subsystem
)

Subsystem Simulink
Simulink
Inport Outport

4-67

Subsystem

Simulink Model Browser(4-95 )

Open
Open
Simulink Edit Open Enter

Go to Parent
Go to Parent
Esc Simulink
View Go to Parent

Simulink File Preferences Simulink Preferences

4-68

Window reuse type 1

Open

Go to Parent (Esc)

none

reuse

replace

mixed

Simulink Subsystem

Inport Outport
( )
Format Hide Port Labels (
Show Port Labels)
Inport Outport Format
Hide Name ( Show Name)
Show port labels

4-69

2 2
Inport 1 Outport Subsystem

Access ReadOnly
NoReadOrWrite

9-228 Subsystem

(4-77 )

4-70

MATLAB

OpenFcn

set_param ( 10-27 set_param )


mymodel Test
testvar
set_param(mymodel/Test, OpenFcn, testvar)

clutch
(clutch.mdl)

Simulink
Simulink
Preferences (2-15 Simulink )
Callback tracing set_param(0, CallbackTracing, on)
Simulink
MATLAB

4-71

CloseFcn

PostLoadFcn

InitFcn

PostSaveFcn

PreLoadFcn

PreSaveFcn

StartFcn

StopFcn

StopFcn

4-72

CloseFcn

close_system

CopyFcn

Subsystem (
CopyFcn
Subsystem
)add_block

DeleteFcn

Subsystem

DestroyFcn

InitFcn

LoadFcn

Subsystem

ModelCloseFcn

Subsystem

MoveFcn

NameChangeFcn

Subsystem

NameChangeFcn

4-73

4-74

OpenFcn

Subsystem

open_system
OpenFcn

ParentCloseFcn

new_system (10-22 new_system


)

PreSaveFcn

Subsystem

PostSaveFcn

Subsystem

StartFcn

S-Function
StartFcn mdlProcessParameters

Writing S-Functions 3 "Overview of the C


MEX S-Function Routines"

StopFcn

S-Function
StopFcn mdlTerminate
Writing S-Functions 3
"Overview of the C MEX S-Function Routines"

UndoDeleteFcn

CloseFcn

close_system

CopyFcn

Subsystem (
CopyFcn
Subsystem
)add_block

DeleteFcn

Subsystem

DestroyFcn

InitFcn

LoadFcn

Subsystem

ModelCloseFcn

Subsystem

MoveFcn

NameChangeFcn

Subsystem

NameChangeFcn

4-75


Simulink

466
(4-100
)


439 424

MATLAB

4-76

( )

Library File New Library

Library block -
Reference block
Link
Simulink
Copy

link

library
block
Library (Source)

copy

reference
block

Model or Library (Destination)

File New Library


Simulink Library: untitled

4-77

new_system(newlib, Library)

newlib
open_system
10
(
)

Edit
Unlock Library

(4-11 )
(4-83
)

Simulink

(4-79
)

MATLAB Simulink

unresolved Simulink

4-78

Failed to find block "source-block-name"


in library "source-library-name"
referenced by block
"reference-block-path".

( )

MATLAB Edit
Update Diagram

Apply Close

Simulink

Edit
Link options Disable link
Link Options Restore link

Simulink

Simulink

4-79

Simulink

Simulink
Simulink

Simulink

Edit
Link options Propagate/Discard
changes
Link options View changes

Simulink


Edit Update Diagram

get_param ( 4-81 )
LinkStatus
find_system

4-80

Edit Break Library Link


LinkStatus none

set_param(refblock, LinkStatus, none)

save_system(sys, newname, BreakLinks)

Edit
Link options Go To Library Link
Simulink (
)

LinkStatus

none

resolved

resolved

unresolved

unresolved

implicit

inactive

4-81

library link

Format Library Link Display


User( ) All(
)

libinfo

libdata = libinfo(sys)

sys n 1
n sys
4
Block

4-82

Library
ReferenceBlock
LinkStatus'resolved' 'unresolved'

Library Browser
Library Browser MATLAB
Simulink Library
Browser MATLAB Simulink

Microsoft Windows

4-83

Documentation Pane

Tree Pane

Icon Pane

/
+/- +/- /
/

4-84

Find
Find

Simulink Open Library


Open Library

New
Open

slblocks.m
slblocks.m slblocks.m
MATLAB
which(slblocks.m, -all)

slblocks.m

4-85

MATLAB

4-86

Simulink 1

TF = 9/5(TC) + 32

Sources Ramp
Sources 32 Constant
Math 9/5 Gain
Math 2 Sum
Sinks Scope

( )
Gain Constant
Close

4-87

Ramp Initial
output 0 Gain 9/5
Sum 32
Scope Simulation
Start 10

x ( t ) = 2x ( t ) + u ( t )
u(t) 1 1 / Integrator
x x
Gain Sum Signal
Generator Wave form Square
rad/sec Scope
Gain
Gain
Format Flip Block Integrator
Gain Ctrl
425

Sum Integrator Gain


x Integrator x
x

4-88

Scope x 10

Transfer Fcn u x
x/u x sx

sx = 2x + u
x
x = u (s + 2)

x u = 1 (s + 2)
Transfer Fcn
1 s+2 s
[1]( 1) [1
2]

4-89

File Save Save As


Simulink
(.mdl )

B
Save
31

Save
Save As

Simulink
1 mdl

2 Simulink PreSaveFcn

PreSaveFcn
3 Simulink mdl

4 Simulink PostSaveFcn

PostSaveFcn
5 Simulink

Simulink
. err
Simulink
2 4

4-90

File Print (Microsoft Windows


) MATLAB print (
)
Microsoft Windows Print

Print
Print Print Print


Print
Microsoft Windows

4-91

Current system and below All systems


2 All systems

Look Under Mask Dialog

Simulink
Expand Unique Library Links

1
4-77

Include Print Log


Frame

MATLAB

frameedit

Print
print

4-92

print ssys device filename


sys s
sys

device

Using MATLAB Graphics


filename PostScript filename
filename

untitled
print suntitled

Sub1

print sSub1

Requisite Friction

print (['sRequisite Friction'])

2 Friction Model
2

cr = sprintf('\n');
print (['sFriction' cr 'Model'])

print(['-s', gcb])

Simulink
set_param PaperType
PaperOrientation

4-93

( A-1
)MATLAB orient
Windows Print
Printer Setup

PaperPositionMode PaperPosition
PaperPosition
[left bottom width height] 2
2
PaperPositionMode manual Simulink
(
)
vdp
set_param(vdp, PaperType, usletter)
set_param('vdp', 'PaperOrientation', 'landscape')
set_param(vdp, PaperPositionMode, manual)
set_param(vdp, PaperPosition, [0.5 0.5 4 4])
print -svdp

vdp U.S.

PaperPositionMode auto Simulink

4-94

Simulink

Simulink Edit Find Simulink Find

4-95

Find dialog box Filter options ( 4-97


) Search criteria ( 4-97

Finder Start in system


Find Finder

Finder

Simulink ( )

Type
1 2

4-96

Parameter Properties

Filter options

Object type

Object type list. object type list Finder

Finder

Look inside masked subsystem. Finder

Look inside linked systems. Finder

Search criteria

Basic. Basic

Find what

Find what

4-97

Search block dialog


parameters
Advanced. Advanced
7

Advanced Property 1

Value
Finder Select

Match case.

Other match options. Match case

Match whole word

Contains word

4-98

Regular expression

\.. .a .2
wo-

0
ba* b, ba, baa

1
ba+ ba, baa

[]

[a-zA-Z0-9_]+ foo_bar1 foo$bar


^
1
[^0-9]

\w

([a-z_A-Z0-9])

\W

([^a-z_A-Z0-9])

\d

([0-9] )

\D

([^0-9] )

\s

([ \t\r\n\f] )

4-99

\S

([^ \t\r\n\f] )

\<WORD\>

WORD WORD




source control system MATLAB Users Guide 8
"Interfacing with Source Control Systems"
Microsoft Windows UNIX

Windows
Model Browser Simulink View Model
Browser 2

Browser initially visible

Simulink File Preferences

4-100

+/- /
+/- /
/

. /

/ +/-

4-101

Simulink Preferences
Simulink
View Model browser options Show library links

Simulink
Preferences
Simulink View Model browser options
Look under masks

UNIX
File Show Browser

Current
system and
subsystems
it contains

4-102

Blocks in
the selected
system

File Print, Close Model, Close Browser


Options Open System, Look Into System, Display Alphabetical/
Hierarchical List, Expand All, Look Under Mask Dialog, Expand Library Links

OptionsLook Under [M]ask DialogExpand [L]ibrary


Links Open System Look Into System
Simulink


Help, Print, Close

Simulink OpenFcn

(+)

(-)
[M]

[L] 4-24

[O] open function (OpenFcn)
4-71

4-103

[S] Stateflow

-
Open System
- [M] [O]
Look Into System

([M] )
([L] )

Open System
(Open System
)
OpenFcn
Open System

Look Into System

(+)
(-)

4-104

Options
Display Alphabetical List

4-105

Simulink

Simulink

Simulink
4-114

Simulink Model Parameters

( 4109 )
Simulink Model Info

( 9-159 Model Info


)
Simulink MATLAB
M-
Simulink File Source Control

MATLAB
Interfacing with Source Control Systems,

Simulink
Simulink USER, USERNAME,
LOGIN, LOGNAME
Simulink

UNIX USER
USER
Simulink
Windows
Windows
Simulink " "
MATLAB

4-106

getenv
MATLAB
getenv(user)

USER Windows

Windows95 98 autoexec.bat

set user=yourname

yourname
autoexec.bat
autoexec.bat c:\

4-107

Windows/NT Windows/NT
( )USER

> >

Control Panel USER

USER


OK

4-108

Model Properties

Simulink File Model Properties

Model Properties Pane

Creator. Simulink
USER

Created.
Model description.

4-109

Options Pane
Options

Configuration manager.

Model Info

Configuration manager ( ) Model Info



9-159 Model Info
Model version format. Model Properties Model Info

%<AutoIncrement:#>
# Simulink

1.%<AutoIncrement:2>

4-110

1.2

Simulink # 1

1.%<1.%<AutoIncrement:2>

1.%<1.%<AutoIncrement:3>

Simulink 1.3
Modified by . History Model Info

"Last modified by"


%<Auto>
Simulink USER

Modified date . History Model Info


"Last modified date"
%<Auto>
Simulink

4-111

History Pane
History

Last modified by. Simulink

USER

Last modified date. Simulink

Modified history update.


"Prompt for Comments When Save" Simulink

Simulink
4113

Modified history. Simulink
Edit

4-112

Simulink
Simulink

Simulink Model Properties History


Modified history update "Prompt For Comments When
Save" Simulink Log
Change

Modified Comments
Save
Include "Modified Contents" in "Modified
History"
Show this dialog box next time when save

4-113

Simulink Model Properties


History Edit Simulink
Modification History

Apply OK

Simulink
MATLAB M Simulink get_param

Simulink

4-114

Created

Creator

ModifiedBy

ModifiedByFormat

ModifiedBy
%<Auto>
Simulink USER

ModifiedDate

ModifiedDateFormat

ModifiedDate
%<Auto>
Simulink

ModifiedComment

ModifiedHistory

ModelVersion

ModelVersionFormat

%<AutoIncrement:#>
# Simulink
#
#

Description

LastModificationDate

4-115

Simulink
Simulink Simulink

File MATLAB

Microsoft Windows : Exit MATLAB


UNIX : Quit MATLAB

4-116

. . . . . . . . . . . . . . . . . . . . . . . . . 5-2
. . . . . . . . . . . . . . . . . 5-2
Running a Simulation from the Command Line . . . . . . . . . . 5-3

. . . . . . .
. . . . . . . . . . . .
Simulation Diagnostics . . . .

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

Simulation Parameters
Solver . . . . . . . . . . . .
Workspace I/O . . . . . . . . .
Diagnostics . . . . . . . . . .
. . . . . . . . .

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

. . 5-8
. . 5-8
. 5-18
. 5-25
. 5-29

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

5-4
5-4
5-4
5-4
5-6

. . . . . . . . . . . . .5-34

Speeding Up the Simulation . . . . . . . . . . . . . . . . .


. . . . . . . . . . . . . . .

5-33
5-35

. . . . . . . . .5-36

sim . . . . . . . . . . . . . . . . . . .
Using the set_param Command . . . . . . . . . . . . . . .

5-36
5-35

Simulink
MATLAB

" " MATLAB

ODE




( )Scope Display

-
-
-
-
-

5-2

536

5-3

Simulink Simulation Parameters

Simulation Parameters
Simulink Simulation Parameters

3 " "
Solver

Workspace I/O MATLAB


Diagnostics

58 Simulation Parameters

MATLAB
MATLAB

Apply

Close

Simulation Start
Ctrl-T
Start Stop

5-4

Simulink Simulink

Simulation Stop

Ctrl-T
Simulation Pause
Pause Continue
Continue

Simulation Parameters
Simulink

5-5

Simulation Diagnostics

Simulink Simulation Diagnostics

Click to display error


message.

Double-click to display error


source.

Click to display error source.

Message. ( )
Source. ( )
Fullpath
Summary.
Reported by. ( Simulink, Stateflow,
Real-Time Workshop )

5-6

Simulation Diagnostics Simulink (


)

( )
Open

5-7

Simulation Parameters
Simulation Parameters sim (5-38
sim ) simset( 5-43 simset )

5-1: Simulation Parameters

OK

Cancel

Help

Apply

Solver
Solver Simulation Parameters
Solver
Solver


5-8

Simulation Parameters

Start time Stop time

0.0 10.0

10 10

Simulink (ODE)
Simulink

5-9

Using MATLAB

Simulink

ode45 ode45

ode45 ode15s
5-11
Variable-step solvers
Simulink discrete
ode45
Simulink discrete
2 discrete

0.5 0.75 0.25


discrete

discrete
[0.0 0.25 0.5 0.75 1.0 1.25 ...]

discrete
[0.0 0.5 0.75 1.0 1.5 2.0 2.25 ...]

discrete
discrete
ode45, ode23, ode113, ode15s,
ode23s discrete
ode45 discrete

5-10

Simulation Parameters

ode45 Dormand-Prince Runge-Kutta(4,5)


y(tn) y(tn-1)
ode45 "
"
ode23 Bogacki Shampine Runge-Kutta(2,3)
ode45
ode23
ode113 Adams-Bashforth-Moulton PECE
ode45 ode113

ode15s (NDF)
(BDF)(Gear )
ode113 , ode15s
ode45 ode15s

ode23s 2 Rosenbrock
ode15s
ode15s
ode23t " "

ode23tb
Runge-Kutta TR-BDF
ode23s
ode15s
discrete( )
Simulink

5-11

ode15s ode23s

Shampine, L. F. Numerical Solution of Ordinary Differential Equations, Chapman &


Hall, 1994

ode5, ode4, ode3, ode2, ode1,


discrete .
ode5 Dormand-Prince ode45
ode4 4 Runge-Kutta RK4
ode3 Bogacki-Shampine ode23
ode2 Euler Heun
ode1 Euler
discrete( )

534

( 534
)
Solver

auto

auto

5-12

Simulation Parameters

. Max step size

t stop t start
h max = ----------------------------50

1
(1/4 )

516

2
2 1 2

Diagnostics

5-13

(rtol ) (atol )


1e-3
0.1%

i ei
e i max ( rtol x i , atol i )

rtol*|x|
State

Region in which rtol determines acceptable error


Region in which atol determines acceptable error

atol
Time
auto ( ) Simulink
1e-6 Simulink

0 1 reltol
1e-3 abstol 1e-3
0 1000 abstol 1

5-14

Simulation Parameters

Integrator

ode15s
ode15s 1 5 NDF

2 (NDF
A- )ode15s

1 ( A- )
ode23s

Multitasking
Simulation Parameters
Solver Mode
1
MultiTasking.

rate transition
Simulink 2 Unit Delay( 9-254 Unit Delay )
Zero-Order Hold ( 9-262 Zero-Order Hold )

Unit Delay

Zero-Order Hold Real-Time Workshop


Users Guide 7 " "

5-15

SingleTasking.

Auto. Simulink

Output options
3

Refine output
Produce additional output
Produce specified output only
. Refine output

ode45
ode45


( 3-14 )

5-16

Simulation Parameters

. Produce additional output

Simulink Solver Ouput Times


MATLAB

Produce specified output only


0, 2.5, 5, 8.5, 10

Refine output 2

0, 1.25, 2.5, 3.75, 5, 6.75, 8.5, 9.25, 10

5-17

Produce additional output [0:10]

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Produce Specified Output Only [0:10]

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

[1:100]*0.01

[1:0.01:100]

Workspace I/O

Simulation Parameters
Workspace I/O

5-18

Simulation Parameters

Simulink

Workspace I/O Load from workspace Input


( )
Apply

Array. Load from workspace Input


Workspace I/O Format Matrix
Simulink Input

double ( )

( )Inport

Simulink Interpolate data


( 9-123
Interpolate data )
n + 1 n

[t,u]
t u
Input
2 1 2
1
u t
t = (0:0.1:1);
u = [sin(t), cos(t), 4*cos(t)];

double ( )
double (2-D)

5-19

Structure with time. Simulink Input

2 time signals
time signals

values values

signals values dimensions 2


values
time
dimensions
1-D dimensions
1)
2-D dimensions 2
1 2
values M
N M time
N
int8 2 11

a.time = (0:0.1:1);
c1 = int8([0:1:10]);
c2 = int8([0:10:100]);
a.signals(1).values = [c1 c2];
a.signals(1).dimensions = 2;

Workspace I/O Input


a
(2-D ) Mx N T
M N T
4 5 51 1

[4 5] 4 5 51

5-20

Simulation Parameters

1 2
a

a.time = (0:0.1:1);
a.signals(1).values = sin(a.time);
a.signals(1).dimensions = 1;
a.signals(2).values = cos(a.time);
a.signals(2).dimensions = 1;

Input a
I/O Structure with time

Simulink Structure with time


5-23
Structure with time

Structure. time
Structure with time
time
a.time = []

Simulink 1
2 2

Simulink Structure
5-24 Structure

5-21

Per-Port Structures.
signals
Input
in1, in2, ..., inN
in1 in2
2

Time Expression.
MATLAB 2
1 timefcn 2

[3*sin(t), cos(2*t)]
4*timefcn(w*t)+7

Simulink

Simulink t 1

Simulink sin sin(t)

Saving Output to the Workspace


Save to workspace Time, States, Output

Simulink ( )

Simulink Save to Workspace

Simulink
To Workspace
( 9-240 To Workspace )

5-22

Simulation Parameters

Save options

Array. Simulink

Save to Workspace ( xout)

2
2
2 1 2
2
Save to Workspace ( yout)


(
)

Structure with time. Save to


Workspace

2 time signals time


signals
4
values, dimensions, label, blockName values

values time
2-Dvalue
M 3-
=1 MATLAB
label

5-23

dimensions label
blockName
outport

2 time signals time


signals

signals 4 valuesdemensionlabelblockName
values blockName
label
state CSTATE( ) DSTATE( )
S- label S-

values

values
2 2 51
Simulink values
51 4
2 1
2 2
Structure. Simulink time

Per-Port Structures.
signals
Output
out1, out2, ..., outN
out1 out2 2

Limit data points to last

Decimation
2 1

5-24

Simulation Parameters

States

WorkspaceI/O
Save
( ) Final State

Initial State
save final states
Simulink Structure Structure with time

([])
Simulink

Diagnostics

Simulation Parameters Diagnostics

5-25

Simulink ODE
S- Simulink

( 40%) off
S-

Simulink
( )

1 t ( )

t
(ode23s ode15s)
Simulink

Simulink

5-26

Simulation Parameters

Simulink

S-

S-

-1

(Sine Wave ) -1

Simulink

318

Product
(9-170 Product )

4-45

5-27

5-28

(Continued)

int32 float

32-bit
4-45

514 514

2
(5-15 Multitasking
)

S-function

S-function

(4-31
)

2
(5-15 Multitasking
)

9-49
Data Type Conversion

Simulation Parameters

(Continued)

(436
)

.
() ( 35
)

Simulink

(5-32 )

5-29

MATLAB


(
)

Simulink

(Ctrl+D)

Simulink

Boolean . Boolean
boolean double

double boolean
Boolean
Boolean

5-30

Simulation Parameters

double
Simulink Simulink

. (
Real-Time Workshop )

.
Simulink
Simulink

C-MEX S-function
Scope Display

Simulink

Scope Display

314

5-31

(529 )

MATLAB
MATLAB
Referenced workspace variables

.
MATLAB

5-32

Simulation Parameters

MATLAB

. Real-Time Workshop

. Real-Time
Workshop

5-33

MATLAB Fcn MATLAB Fcn


MATLAB

Fcn Elementary Math


M- S- M-
S- MATLAB
S- C-MEX
S-
Memory Memory
(ode15s ode113) 1


(auto)

(0.1% )

5-14



ode15s

5-34

3-18
Random Number Integrator
Sources Band-Limited White Noise

1e-4 (
1e-3)

" "


ode15s
2 ( A-
)ode23s

Integrator

5-35

MATLAB M

sim set_param

sim

[t,x,y] = sim(model, timespan, options, ut);

model
Simulation Parameters
sim 5-38 sim
options
simset ( 5-43 simset )
options
5-8 Simulation Parameters

set_param

set_param
get_param
set_param
set_param(sys, SimulationCommand, cmd)

'sys' 'cmd' 'start', 'stop', 'pause', 'continue', 'update'

get_param

get_param(sys, SimulationStatus)

5-36

Simulink stopped, initializing, running, paused, terminating (Real-Time


Workshop )external

5-37

sim

5sim

[t,x,y] = sim(model,timespan,options,ut);
[t,x,y1, y2, ..., yn] = sim(model,timespan,options,ut);

sim Workspace I/O


Simulink

1 ( ) ([])
sim
sim options

Simulation parameters
Workspace I/O (5-18 Workspace I/O )

simset ( 5-43 simset )


solver
VariableStepDiscrete

5-38

Outport
Outport

y1,...,yn

yi n Outport

model

sim

timespan

tFinal 0
[tStart tFinal]
[tStart OutputTimes tFinal] t
t
OutputTimes Produce additional
output

options

simset
( 5-43 simset )

ut

Inport
ut u = UT(t) (
)MATLAB
vs.
ut1, ut2, ...,
MATLAB

5-19

Simulink vdp Van der Pol

[t,x,y] = sim(vdp)

Refine vdp
Van der Pol

[t,x,y] = sim(vdp, [], simset(Refine,2));

1,000 Van der Pol


100 t y
xFinal

5-39

sim
[t,x,y] = sim(vdp, 1000, simset(MaxRows, 100,
OutputVariables, ty, FinalStateName, xFinal));

5-40

simset, simget

simplot

5simplot

simplot(data);
simplot(time, data);

simplot Handle Graphics figure


Scope
figure

data

( Outport To
Workspace ) Array,
Structure, Structure with time
(5-18 Workspace I/O )

time

Array Structure

simplot Structure with time

figure

5-41

simplot

vdp
set_param(gcs, SaveOutput, on)
set_param(gcs, SaveFormat, StructureWithTime)
sim(gcs)
simplot(yout)

figure vdp

5-42

sim, set_param

simset

5simset

options = simset(property, value, ...);


options = simset(old_opstruct, property, value, ...);
options = simset(old_opstruct, new_opstruct);
simset

simset
options

sim

options = simset(property, value, ...) options

options = simset(old_opstruct, property, value, ...) old_opstruct

options = simset(old_opstruct, new_opstruct) old_opstruct new_opstruct 2

options new_opstruct
old_opstruct

simset

get_param set_param

AbsTol

{1e-6}

.
AbsTol
Decimation

{1}

. t, x, y
1 2
1

5-43

simset
DstWorkspace

base | {current} | parent

. To
Workspace

FinalStateName

string {}

. Simulink

FixedStep

positive scalar

50 1
InitialState

vector {[]}

. ( )
( )
InitialState

InitialStep

positive scalar {auto}

.
InitialStep

MaxOrder

1 | 2 | 3 | 4 | {5}

ode15s . This property applies only to ode15s.


MaxDataPoints

nonnegative integer {0}

. t, x, y
MaxRows 0

MaxStep

positive scalar {auto}

.
50 1
OutputPoints

{specified} | all

. specified timespan
t, x, y all t, x, y

5-44

simset

OutputVariables

{txy} | tx | ty | xy | t | x | y

. t, x, y
t, x, y
Refine

positive integer {1}

.
Refine
Refine
RelTol

positive scalar {1e-3}

e(i) <= max(RelTol*abs(x(i)),AbsTol(i))

0.1%
1e-3
Solver

VariableStepDiscrete |
ode45 | ode23 | ode113 | ode15s | ode23s |
FixedStepDiscrete |
ode5 | ode4 | ode3 | ode2 | ode1

SrcWorkspace

{base} | current | parent

.
MATLAB
Trace

minstep, siminfo, compile {}

.
( 1 )
'minstep'

Simulink

siminfo

compile

5-45

simset
ZeroCross

{on} | off

/
off

MaxRows Refine
myopts

myopts = simset(MaxDataPoints, 100, Refine, 2);

vdp model 10 myopts

[t,x,y] = sim(vdp, 10, myopts);

5-46

sim, simget

simget

5simget

struct = simget(model)
value = simget(model, property)
value = simget(OptionStructure, property)

simget Simulink

simget

struct = simget(model) Simulink

sim simset

value = simget(model, property)

value = simget(OptionStructure, property)

OptionStructure
property

vdp
options = simget(vdp);

vdp Refine
refine = simget(vdp, Refine);

sim, simset

5-47

simget

5-48

. . . . . . . . . . . . . . . . . . . . . . . . 6-2

Scope . . . . . . . . . . . . . . . . . . 6-2
. . . . . . . . . . . . . . . . . . . . . 6-2
To Workspace . . . . . . . . . . . . . . . 6-3
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
. . . . . . . . . . . . . . . . . . . . . . . . . 6-7
linfun . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9
trim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-12

Simulink 3

Scope XY Graph
MATLAB
To Workspace MATLAB

Scope
Scope
Scope

Scope Scope

XY Graph

MATLAB

Out Signals & Systems Outport


yout
5-18 Workspace I/O

Simulation Parameters
Workspace I/O

6-2

Simulation

plot(tout,yout)

To Workspace
To Workspace MATLAB

y t
Clock To Workspace

Simulation Parameters Workspace I/O


sim
( 5-18 Workspace I/O
)
To Workspace

6-3

Simulink A, B, C, D
linmod dlinmod

x = Ax + Bu
y = Cx + Du
x, u, y
lmod

Simulink

[A,B,C,D] = linmod(lmod)
A=
-2 -1 -1
1 0 0
0 1 -1
B=
1
0
0
C=
0 1 0
0 0 -1
D=
0
1

6-4

Signals & Systems Inport Outport


Sources
Sinks Inport
Sum Sources
LTI
Control System Toolbox

LTI :
sys = ss(A,B,C,D);

:
bode(A,B,C,D) or bode(sys)
:
step(A,B,C,D) or step(sys)
impulse(A,B,C,D) or impulse(sys)
lsim(A,B,C,D,u,t) or lsim(sys,u,t)
Control System Toolbox Robust Control Toolbox

linmod

[A,B,C,D] = linmod(sys, x, u, pert, xpert, upert)

dlinmod 2
linmod
6-9 linfun

Derivative Transport Delay


linmod

Simulink Extras Linearization


Extras Blocksets & Toolboxes

6-5

Derivative Switched derivative for linearization


Transport Delay Switched transport delay for linearization
( Control System Toolbox )
Derivative
Transfer Fcn
Derivative Transfer Fcn
(

s
----------s+a

6-6

Simulink trim lmod

trim 1
(x) (u)
(y)
x = [0; 0; 0];
u = 0;
y = [1; 1];

ix = []; % Dont fix any of the states


iu = []; % Dont fix the input
iy = [1;2]; % Fix both output 1 and output 2

trim

[x,u,y,dx] = trim(lmod,x,u,y,ix,iu,iy)
x=
0.0000
1.0000
1.0000
u=
2
y=
1.0000

6-7

1.0000
dx =
1.0e015 *
-0.2220
-0.0227
0.3331

trim
trim
6-12 trim

6-8

linfun

6linfun

[A,B,C,D] = linfun(sys, x, u)
[num,den] = linfun(sys, x, u)
sys_struc = linfun(sys, x, u)

linfun

linmoddlinmod linmod2

sys

Simulink

xu

linmod Simulink
linmod
A, B, C, D

x = Ax + Bu
y = Cx + Du
Inport Outport Simulink

[A,B,C,D] = linmod(sys, x, u) x u sys


x u

[num,den] = linfun(sys, x, u)
sys_struc = linfun(sys, x, u)

dlinmod

dlinmod linmod 2

[Ad,Bd,Cd,Dd] = dlinmod(sys, Ts, x, u);

6-9

linfun
Ts x u

Ts 0

dlinmod Ts
( )
Ts

-
dlinmod [A,B,C,D]
Ad
Ts>0

all(abs(eig(Ad))) < 1

Ts = 0

all(real(eig(Ad))) < 0

dlinmod Ad Bd
Ad
dlinmod

bode

pert 2 2
t
Simulink

6-10

linfun

[sizes,x0,xstring] = sys

xstring i i

ss2tf
ss2zp -
ss LTI
LTI LTI tf zpk
- -
Derivative Transport Delay
6-4

6-11

trim

6trim

[x,u,y,dx] = trim(sys)
[x,u,y,dx] = trim(sys,x0,u0,y0)
[x,u,y,dx] = trim(sys,x0,u0,y0,ix,iu,iy)
[x,u,y,dx] = trim(sys,x0,u0,y0,ix,iu,iy,dx0,idx)
[x,u,y,dx] = trim(sys,x0,u0,y0,ix,iu,iy,dx0,idx,options)
[x,u,y,dx] = trim(sys,x0,u0,y0,ix,iu,iy,dx0,idx,options,t)
[x,u,y,dx,options] = trim(sys,...)

trim

trim

trim
min-max
trim

[x,u,y] = trim(sys) x0

trim [x-x0,u,y]
trim
abs(dx-0)
x0
[sizes,x0,xstr] = sys([],[],[],0)
[x,u,y] = trim(sys,x0,u0,y0) x0,u0,y0
abs([x-x0; u-u0; y-y0])

trim(sys, x0, u0, y0, ix, iu, iy)

x0, u0, y0
ix, iu, iy x0, u0, y0

6-12

trim

trim

abs([x(ix)-x0(ix); u(iu)-u0(iu); y(iy)-y0(iy)])

[x,u,y,dx] = trim(sys, x0, u0, y0, ix, iu, iy, dx0, idx)

dx0 idx
dx0
options trim

trim
options
trim

No.

0 1
-1

0.0001

0.0001

0.0001

10

N/A

6-13

trim
options Optimization Toolbox Users Guide

x = Ax + Bu
y = Cx + Du
A, B, C, D sys
A = [-0.09 -0.01; 1 0];
B = [ 0 -7; 0 -2];
C = [ 0 2; 1 -5];
D = [-3 0; 1 0];

[x,u,y,dx,options] = trim(sys)
x=
0
0
u=
0
y=
0
0
dx =
0
0

6-14

trim

options(10)
ans =
7

x = [1;1], u = [1;1]
x0 = [1;1];
u0 = [1;1];
[x,u,y,dx,options] = trim(sys, x0, u0);
x=
1.0e11 *
-0.1167
-0.1167
u=
0.3333
0.0000
y=
-1.0000
0.3333
dx =
1.0e11 *
0.4214
0.0003

options(10)
ans =
25

1
y = [1;1];
iy = [1;2];
[x,u,y,dx] = trim('sys', [], [], y, [], [], iy)
x=
0.0009
-0.3075
u=

6-15

trim
-0.5383
0.0004
y=
1.0000
1.0000
dx =
1.0e-16 *
-0.0173
0.2396

1 0 1

y = [1;1];
iy = [1;2];
dx = [0;1];
idx = [1;2];
[x,u,y,dx,options] = trim(sys,[],[],y,[],[],iy,dx,idx)
x=
0.9752
-0.0827
u=
-0.3884
-0.0124
y=
1.0000
1.0000
dx =
0.0000
1.0000

options(10)
ans =
13

6-16

trim

trim

x, u, y

trim
Optimization Toolbox Users Guide

6-17

trim

6-18

. . . . . . . . . . . . . . . . . . . . . . . . . 7-2

. . . . . . . . . . . . . . 7-3

. . . . . . . . 7-4
. . . . . . . . . . . . 7-6
. . . . . . . . . . . . . . . . . . 7-6
Mask Editor:

. . . . . . . . . . . . . . . . . . . . . 7-8

Initialization . . . . . . . . . . . . . . . . . . . . . 7-9

. . . . . . . . . . . . .

. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .

.
.
.
.

.
.
.
.

. . 7-9
. 7-13
. 7-13
. 7-13

Icon . . . . . . . . . . . . . . . .
. . .

. . . . . . . .
. . .
. . . . . . . . .

.
.
.
.
.
.

.
.
.
.
.
.

. .7-17
. 7-17
. 7-19
. 7-20
. 7-21
. 7-22

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

Documentation . . . . . . . . . . . . . . . . . . . .7-26

Mask Type . . . . . . . . . . . . . . . . . .
Block Description . . . . . . . . . . . . . . .
Mask Help Text . . . . . . . . . . . . . . . .
Self-Modifying

7-26
7-26
7-27

. . . . . . . . . . . . .7-28

. . . . . . . . .7-29

. . . . . . .
. . . . . . . . . . .

7-29
7-30

Simulink

7-2

y = mx + b

Subsystem Subsystem
mx + b Gain
m Slope Gain
b Intercept Constant

Subsystem

Slope Intercept
Simulink

Slope Intercept

Simulink

7-3


(
1

Subsystem
Edit Mask Subsystem
Mask Editor
Initialization

7-4

Mask Editor
-
-

Slope
Intercept

( 7-14 )


m Slope

Mask Editor

OK
Subsystem
Slope 3 Intercept
2

7-5

Documentation

mx + b
Subsystem Simulink

7-6

Icon
Icon

(0,0) (0,m)
1

Drawing coordinates
Normalized (0,0) (1,1)

7-19

7-7

Mask Editor:
(Subsystem )
Subsystem Edit Mask Subsystem
Mask Editor Mask Editor 3

Initialization

Icon
Documentation

Mask Editor 5
OK Mask Editor

Cancel Mask Editor


Apply
Unmask Mask Editor

Create Mask Mask Editor

Help
Apply
Mask Editor
Subsystem
Edit Look Under Mask

7-8

Initialization

Initialization

Initialization

mx+b Initialization

Prompt

Assignment Evaluate
MATLAB Literal

7-9

gain Assignment
Evaluate gain MATLAB
Literal MATLAB
gain
Literal
MATLAB eval
LitVal gain

value = eval(LitVal)

Evaluate Assignment

Prompt
Variable

Add
2 Prompt

Variable

2 Enter

Return Simulink

7-10

Initialization

1
2 Delete

1
2 1

Up
Down

Simulink

3
3
( )

7-11

(freq)
Assignment
Assignment

Evaluate

Literal

(label)
Assignment

on

off


Popup strings (|)

7-12

Initialization

(color)
Assignment

Assignment

Evaluate

1
3 3

Literal

3
'green'

1
2

4-77

MaskTunableValues

1
2 2

on off
get_param

7-13

on off
set_param MaskTunableValues

ca = get_param(gcb, MaskTunableValues);
ca(1) = off
set_param(gcb, 'MaskTunableValues, ca)

(
)
Simulink



MATLAB MATLAB

Simulink

7-14

Initialization

mx + b Mask Editor
m b

( )
( )

M-
Mask
Editor M-
" "

7-15

M
A A B
B A M
x x A


keyboard keyboard

MATLAB
dbstop if error
dbstop if warning

dbstop

7-16

Icon

Icon
Icon
Drawing commands

Icon

disp(text) or disp(variablename)

7-17

text(x, y, text)
text(x, y, stringvariablename)
text(x, y, text, horizontalAlignment, halign, verticalAlignment, valign)
fprintf(text) or fprintf(format, variablename)
port_label(port_type, port_number, label)

disp text variablename

text (x,y) (text


stringvariablename ) Drawing coordinates

7-22

text (x,y)

text(0.5, 0.5, foobar, horizontalAlignment, center)

"foobar"
text

left

right

center

text

7-18

base

bottom

middle

Icon

cap

top

fprintf
variablename text

MATLAB

\n
disp 2

port_label

port_label(port_type, port_number, label)

port_type input outputport_number label

port_label(input, 1, a)

1 a

1 plot
plot

plot(Y);
plot(X1,Y1,X2,Y2,...);

7-19

plot(Y) Y

Y
plot(X1,Y1,X2,Y2,...) X1 Y1X2 Y2

Sources Ramp

plot([0 1 5], [0 0 4])

NaN inf NaN inf


Simulink NaN inf
Drawing coordinates
7-22

Simulink 3 (? ? ?)

image patch
Bitmap
image(a) a

a m n 3 RGB

Bitmap MATLAB
imread ind2rgb
image(imread(icon.tif))

7-20

Icon

MATLAB icon.tif TIF

image(a, [x, y, w, h])

image(a, [x, y, w, h], rotation)

(on) (off) off


patch(x, y) x, y
foreground
patch(x, y, [r g b]) [r g b]
r g b
patch([0 .5 1], [0 1 0], [1 0 0])

Drawing commands

dpoly(num, den)
dpoly(num, den, character)
num den
character
s

s
dpoly(num, den)

num = [0 0 1]; den = [1 2 1];

7-21

dpoly(num, den, z)

num = [0 0 1] den = [1 2 1]

1/z
dpoly(num, den, z-)

num den

- -
droots(z, p, k)

z = []; p = [-1 -1]; k = 1;

4 (z z-) z 1/z

Simulink 3 (? ? ?)
Simulink

Drawing commands

7-22

Icon

Icon frame(
Icon frame
Visible Invisible

AND

Visible

Invisible

Icon transparency(
Opaque
Transparent Opaque
Simulink AND
(opaque) (transparent)

Opaque

Transparent

Icon rotation(

AND
Fixed ( ) Rotates ( )

Fixed

Rotates

7-23

Drawing coodinates(

plot text Autoscale,


Normalized, Pixel
max(X), max(Y)

min(X), min(Y)

Autoscale

1,1

0,0

Normalized

block width, block height

0,0

Pixel

Autoscale

X = [0 2 3 4 9]; Y = [4 6 3 5 8];

(0,3) (9,8) x 9 (0
9) y 5 (3 8)
Normalized (0,0) (1,1)
0 1 X Y

X = [.0 .2 .3 .4 .9]; Y = [.4 .6 .3 .5 .8];

Pixel X Y

mx + b

7-24

Icon

pos = get_param(gcb, Position);


width = pos(3) pos(1); height = pos(4) pos(2);
x = [0, width];
if (m >= 0), y = [0, (m*width)]; end
if (m < 0), y = [height, (height + (m*width))]; end

plot(x,y)

7-25

Documentation
Documentation

Documentation mx+b

Mask Type

Mask
Editor
Simulink
"(mask)"

Block Description

7-26

Documentation

Simulink Enter
Return

Mask Help Text


Help

URL (http:, www, file:, ftp:, mailto:


web (
eval (MATLAB )
Web Static
Simulink 1 URL
web eval

web([docroot /My Blockset Doc/ get_param(gcb,MaskType)... .html])


eval(!Word My_Spec.doc)
http://www.mathworks.com
file:///c:/mydir/helpdoc.html
www.mathworks.com

Simulink

7-27

Self-Modifying

self-modifying MaskSelfModifiable
on Simulink

MaskSelfModifiable self-modifying
MATLAB
set_param(gcb, MaskSelfModifiable, on);

7-28

Simulink

Simulink

Simulink set_param

MATLAB Simulink set_param

Simulink

Simulink
get_param set_param
set_param

MATLAB set_param

7-29

set_param

Simulink

MaskCallbacks

1 1
2 2

MATLAB M

MATLAB set_param

set_param(gcb,MaskCallbacks,{parm1_callback, ,... parm3_callback});

1 3

MaskDescription

MaskEnables

1 1
2 2

on
off

7-30

set_param(gcb,MaskEnables,{on,on,off});

3
Simulink

MaskPrompts

1 1
2 2

MaskType

MaskValues

1 1
2 2

MaskVisibilities

on off

set_param(gcb,MaskVisibilities,{on,off,on});

7-31

2
Simulink

7-32

. . . . . . . . . . . . . . . . . . . . . . . . . 8-2

Enabled . . . . . . . . . . . . . . . . . . . . 8-3

Enabled . . . . . . . . . . . . . . . . . 8-3
Enabled . . . . . . . . 8-5
Triggered . . . . . . . . . . . . . . . . . . . 8-8

Triggered . . . . . . . . . . . . . . . . 8-9
Function-Call . . . . . . . . . . . . . . . . 8-10
Triggered . . . . . . 8-10
Triggered and Enabled . . . . . . . . . . . . . .8-12

Triggered and Enabled . . . . . . . . . .


Triggered and Enabled . . . . . . . .
. . . . . . . . . . . .

8-12
8-13
8-13

Subsystem

Simulink 3
enabled
( )
Enabled
8-3 Enabled
triggered subsystem ""

Triggered 8-8
Triggered
triggered and enabled
Enable Triggered and
Enabled 8-12 Triggered and Enabled

8-2

Enabled

Enabled
Enabled

Enabled

Simulink

Enabled
Enabled Signals & Systems Enable
Simulink Enable
Enable Subsystem .

8-3

Enabled
Enabled

Outport
Output when disabled

held
reset
Initial output

Outpurt

Enabled

Enable
States when enabling

held
reset

8-4

Enabled

Enable
Enable Enable
Show output port

Enabled
Enabled (1
)

Enabled
Enabled
Enabled

Enabled

Enabled GoTo
Enabled GoTo
Enabled GoTo Simulink
clutch

8-5

4 1

0.25 Block A
0.5 Block B
0.125 Enabaled Block C
0.25 Enabaled Block D
Enable Signal E Pulse Generator
0.375 0 1 0.875 0 .

1
0

Signal E

- Start of execution

Block D

for a block

Block C
Block B
Block A
0

.125 .25 .375 .50 .625 .75 .875 1.0


Time (sec)

8-6

Enabled

Block A Block B Enabled Enable


Enable Block C D Enable

Enable 0.875 C

8-7

Triggered
Triggered

Triggered
1 3
Triggered
rising (
)
falling (
)
either rising falling
rising(R) falling(F)

0
F

Triggered

8-8

Triggered

Triggered
Triggered Signals & Systems Trigger
Simulink Trigger
Subsystem

Trigger
Trigger type

rising

falling

either
.

Simulink Trigger Subsystem


Subsystem

8-9

Enabled Triggered
Triggered

Trigger
Show output port

Output data type auto, int8, double


auto
(int8 double)

Function-Call
S-function Triggered

function-call
Writing S-Functions

Triggered
Triggered
Triggered

Logical Operator Gain

8-10

Triggered

-1 -1

8-11

Triggered and Enabled


3 2
triggered and enabled
Enabled
Triggered .
Trigger event

Is
the enable
input signal
>0?

No
Dont execute the subsystem

Yes
Execute the subsystem
Triggered and Enabled Enable Trigger
Simulink Enable
Enable
Simulink
1

Triggered and Enabled


Triggered and Enabled Signal & Systems Enable
Trigger
Simulink Enable Trigger
Enable Trigger Subsystem

8-12

Triggered and Enabled

Enabled Triggered and Enabled


8-4

8-4

Enable Trigger

Triggered and Enabled


Triggered and Enabled

Merge

Enabled Merge

8-13

AC DC

"pos" AC
"neg"
Merge
Mux
Mux Scope

8-14

. . . . . . . . . . . . 9-2
Simulink . . . . . . . . . . . . . . . . . 9-3




(
)

- -
3-18

- - (
)

3-23

- -

4-36

- -
- - /

4-30
- - (state event)
3-14

9-2

Simulink

Simulink
Simulink
simulink

Sources
Sinks

Discrete
Continuous
Math
Functions & Tables

Nonlinear
Signal & Systems

Blocksets and Toolboxes Extra

Demos MATLAB Simulink

Simulink (Windows ) MATLAB


simulink3

Blocksets and Toolboxes Demos

9-1: Sources

Band-Limited White Noise

Chirp Signal

9-3

9-1: Sources (Continued)

Clock

Constant

Digital Clock

Digital Pulse Generator

From File

From Workspace

Pulse Generator

Ramp

Random Number

Repeating Sequence

Signal Generator

Sine Wave

Step

Step

Uniform Random Number

9-2: Sinks

9-4

Block Name

Display

Scope

Stop Simulation

Simulink

9-2: Sinks (Continued)


Block Name

To File

To Workspace

XY Graph

MATLAB Figure
X-Y

9-3: Discrete

Discrete Filter

IIR FIR

Discrete State-Space

Discrete-Time Integrator

Discrete Transfer Fcn

Discrete Zero-Pole

First-Order Hold

Unit Delay

Zero-Order Hold

9-4: Continuous

Derivative

Integrator

Memory

9-5

9-4: Continuous (Continued)

State-Space

Transfer Fcn

Transport Delay

Variable Transport Delay

Zero-Pole

9-5: Math

9-6

Abs

Algebraic Constraint

Bitwise Logical Operator

Combinatorial Logic

Complex to Magnitude-Angle

Complex to Real-Imag

Derivative

Dot Product

Gain

Logical Operator

Magnitude-Angle to Complex

Math Function

Matrix Gain

Simulink

9-5: Math (Continued)

MinMax

Product

Real-Imag to Complex

Relational Operator

Rounding Function

Sign

Slider Gain

Sum

Trigonometric Function

9-6: Functions & Tables

Direct Look-Up Table (n-D)


Fcn

Look-Up Table

Look-Up Table (2-D)

Look-Up Table (n-D)

MATLAB Fcn

MATLAB

S-Function

S-

9-7

9-7: Nonlinear

Backlash

(
)

Coulomb & Viscous Friction

Dead Zone

( )

Manual Switch

Multiport Switch

Quantizer

Rate Limiter

Relay

Saturation

Switch

9-8: Signals & Systems

9-8

Bus Selector

Configurable Subsystem

Data Store Memory

Data Store Read

Data Store Write

Simulink

9-8: Signals & Systems (Continued)

Data Type Conversion

Demux

Enable

Enable

From

Goto

Goto

From

Goto Tag Visibility

Goto

Ground

Hit Crossing

IC

Inport

Matrix Concatenation

Merge

Model Info

Mux

Outport

Reshape

Probe

Selector

Signal Specification

9-9

9-8: Signals & Systems (Continued)

9-10

Subsystem

Terminator

Trigger

Trigger

Width

Abs

9Abs

Math

Abs

double double

Saturate on integer overflow (integer )


( )

8-bit integers -128 127


16-bit integers -32768 32767
32-bit integers -2147483648 2147483647

N/A

9-11

Abs

9-12

Algebraic Constraint

9Algebraic Constraint

Math

Algebraic Constraint f(z) z

1 (DAE)

Initial guess( )
z Initial guess( )

z2 + z1 = 1
z2 z1 = 1

Display z2 = 1, z1 = 0

Algebraic Constraint double

9-13

Algebraic Constraint

Initial guess( )
0

9-14

Backlash

9Backlash

Nonlinear

Backlash

1 0

( )

-1.0

-0.5

0.5

1.0

3
-
- ( )

- ( )

Initial output( )

2 Backlash
2

Deadband width( )
( )
Initial output( )

9-15

Backlash

(
)
-1.0

-0.5

0.5

1.0

-1.0

-0.5

0.5

1.0

( )

-1.0

-0.5

0.5

1.0

= - ( /2)

2 5
y
u 4 6 5
u < 4 u + 1
u > 6 u - 1

9-16

Backlash

Backlash

Backlash (
1 0 ) (0.5
) Blacklash
(1.0 )
0

A
C

Backlash double

9-17

Backlash

Deadband width( )
1
Initial output( )
0

9-18

Band-Limited White Noise

9Band-Limited White Noise

Sources

Band-Limited White Noise

Random Number Band-Limited White


Noise

0
(PSD)

Simulink

Band-Limited White Noise

1 2
t c --------- ---------100 f max
fmax /

PSD

1/tc tc

Band-Limited White Noise


Noise power( ( ))
PSD

Noise power( ) tc

9-19

Band-Limited White Noise

Band-Limited White Noise double

Noise power( )
PSD 0.1
Sample time( )
0.1
Seed( )
23341

9-20

(Noise power) (Seed)

Bitwise Logical Operator

9Bitwise Logical Operator

Math

Bitwise Logical Operator


(AND, OR, XOR) (NOT), (SHIFT_LEFT, SHIFT_RIGHT)

Bitwise Logical Operator

Bitwise Logical Operator (AND, OR, XOR)

AND

OR

XOR

Bitwise Operator

9-21

Bitwise Logical Operator


5 4 5 4

1-D ( ) 1 1

Second
operand( 2 )
MATLAB
16 ( ,
'FFFF')

'FF00'
uint8 '00'

16
MATLAB ['00' 'FF'] 2
'FF00' ['FFFF';
'0000'] 2 ['FFFF'; '00']
MATLAB
16 10 16

({'F0' '0F'} ) 2 16

9-22

Bitwise Logical Operator

Bitwise Logical Operator NOT


1 0
1

Bitwise Logical Operator SHIFT_LEFT SHIFT_RIGHT

Second operand( 2 )

Bitwise Logical Operator uint8, uint16, uint32

Bitwise operator( )

Second operand( 2 )

MATLAB

9-23

Bitwise Logical Operator

9-24

Second operand

Bus Selector

9Bus Selector

Signals & Systems

Bus Selector Mux Bus Selector

Muxed output( )
Muxed output( )

Simulink Simulink Bus


Selector

Bus Selector

9-25

Bus Selector
Signals in the bus( )
Signals in the bus

>> Signals in the bus

Selected signals( )
Selected signals Up(
)Down( ) Remove( )

Selected signals Bus Selector


???

Muxed output

Bus Selector

9-26

Chirp Signal

9Chirp Signal

Sources

Chirp Signal

Initial frequency( )Target time( )


Frequency at target time( )

Interpret vector parameters as 1-D(


1-D )

(1-D )

Chirp Signal double

Initial frequency( )

0.1 Hz

9-27

Chirp Signal
Target time( )
Frequency at target time

100
Frequency at target time( )

1 Hz
Interpret vector parameters as 1-D( 1-D )
Initial frequencyTarget time
Frequency at target time

9-28

Clock

9Clock

Sources

Clock

Digital Clock

Clock double

Display time( )
Display time
Clock
Decimation( )
Decimation
=
1000 1 1 2
1

N/A

9-29

Clock

9-30

Combinatorial Logic

9Combinatorial Logic

Math

Combinatorial Logic (PLAs)

Memory

Truth table

= 2 ^ ( )

Simulink
1 Simulink 0
1 2
1 m u

= 1 + u(m)*20 + u(m1)*21 + ... + u(1)*2m1

2 AND
2 1 1
0 2 AND
Truth table [0; 0; 0; 1] Combinatorial Logic

" 1"
1
" 2" 2

9-31

Combinatorial Logic
[1 0] 3 (21*1 + 1)
0

3 2 (a b)
- (c) - (c)
(s) 2

Combinatorial Logic Truth table


c s 8 2

9-32

Combinatorial Logic

( )

Combinatorial Logic

Combinatorial Logic Simulink Boolean


logic ( 4-49 Boolean
)
boolean double
Boolean (0 1)
Boolean double
boolean boolean
double Boolean
Combinatorial Logic boolean
double Boolean
double boolean

Truth table( )

Truth table

9-33

Complex to Magnitude-Angle

9Complex to Magnitude-Angle

Math

Complex to Magnitude-Angle double


Output
/ double

Output( )

MagnitudeAndAngle
)Magnitude )Angle
)

9-34

Complex to Real-Imag

9Complex to Real-Imag

Math

Complex to Real-Imag
Output( )
/
( )

Output( )
RealAndImag(
)Real( )Imag( )

9-35

Configurable Subsystem

9Configurable Subsystem

Signals & Systems

Configurable Subsystem
Configurable Subsystem

Configurable Subsystem

Configurable Subsystem

Configurable
Subsystem
Configurable Subsystem
Configurable Subsystem
Configurable Subsystem

Configurable Subystem

Simulink Configurable Subystem

/ Configurable Subystem
/
/ Configurable
Subystem /
Terminator/Ground
/
Configurable Subsystem
Configurable Subsystem

9-36

Configurable Subsystem

AB
A a, b, c d
B a b
e
Configurable Subsystem
a, b, c 3 d e
2

Configurable Subystem a

Configurable Subsystem c A

Configurable Subsystem triggered and enabled


trigger enable I/O
Configurable Subsystem
I/O

configurable subsytem
1 configurable subsystem

2 Configurable Subsystem

Simulink Signals and Systems Configurable Subsystem

3 Configurable Subsystem

9-37

Configurable Subsystem
4 configurable subsystems
5

Configurable Subsystem

Configurable Subsystem Configurable Subsystem

Configurable Subsystem
Library name

List of block choices


configurable subsystem

Port information
Up
Down

9-38

Configurable Subsystem


Configurable Subsystem

Configurable Subystem

Block choice
Configurable Subystem
configurable subsystem

Block choice

Subsystem block

Configurable Subsystem

9-39

Constant

9Constant

Sources

Constant
Constant value Interpret
vector parameters as 1-D
Interpret vector parameters as 1-D
Constant value
1 ( )
2 (
)

Constant ( )
Constant value

Constant value

Interpret vector parameters as 1-D


Constant value

9-40

Constant

9-41

Coulomb and Viscous Friction

9Coulomb and Viscous Friction

Nonlinear

Coulomb and Viscous Friction ( ) (


)

y = sign(u) * (Gain * abs(u) + Offset)

y u Gain Offset
1 1

Coulomb and Viscous Friction double

Coulomb friction value


[1 3 2 0]
Coefficient of viscous friction
1

9-42

Coulomb and Viscous Friction

9-43

Data Store Memory

9Data Store Memory

Signals & Systems

Data Store Memory


Data Store Read Data Store Write

Data Store Memory


Data Store Memory
Data Store Read Data Store Write

Data Store Memory


Data Store Read Data Store Write

Data Store Memory

Data Store Read Data Store Write

Initial value
Data Store Write

9-44

Data Store Memory double

Data Store Memory

Data store name


A
Initial value
0
Interpret vector parameters as 1-D
Initial value

1- ( )

N/A

9-45

Data Store Read

9Data Store Read

Signals & Systems

Data Store Read


Data Store Memory
( )Data Store Write

Data
Store Memory 9-44 Data Store
Memory
Data Store Read

Data Store Read double

Data store name

Sample time

-1

9-46

Data Store Write

9Data Store Write

Signals & Systems

Data Store Write

Data Store Write

Data Store Memory 9-44 Data Store


Memory
Data Store Memory
Data Store Write

Data Store Write


2 Data Store Write

Data Store Write double

Data store name

Sample time

-1

9-47

Data Store Write

9-48

Data Type Conversion

9Data Type Conversion

Signals & Systems

Data Type Conversion Data type

Data type
auto
Data Type Conversion

Saturate on integer overflow

Data Type Conversion

Simulink Simulation Parameters Diagnostics


Data overflow (5-25
Diagnostics )

9-49

Data Type Conversion

9-50

Yes

N/A

Dead Zone

9Dead Zone

Nonlinear

Dead Zone
Start of dead zone End of dead zone

( )



-0.5 0.5

Dead Zone
( ) -0.5 0.5

Dead Zone

9-51

Dead Zone

Start of dead zone


-0.5
End of dead zone
0.5

9-52

Demux

9Demux

Signals & Systems

Demux
(1- ) ( 4-32
oXM ) Number of outputs

Demux Bus selection mode


2
(1
) (1 ) 1 1 (1
1 2 )
Demux Number of outputs

Number of outputs

...

p=n

3
3
3

p>n

p<n

n/p
p

n mod p = 0

6 3
3
2

9-53

Demux

...

p<n
n mod p = m

(n/p)+1
m n/
p p-m

5 3

2 2
1

[p1 p2 ... pm]

p1, p2,

p1+p2+...+pm=n

5
[3,2]
1
3

... pm m

pi > 0

[p1 p2 ... pm]

p1+p2+...+pm=n

-1

some or all
pi = -1

[p1 p2 ... pm]


p1+p2+...+pm!=n
pi = > 0

9-54

pi
pi pi

Demux

-1
[-1, 3 -1] 2
3 1 2

-1
-1
7 [-1, 3 -1]
1 2 2 3
3 2

Number of outputs

9-55

Demux

2 2


5 [3,2]
1 3
2 2

Demux
{{[2 2], 3} {1}} 2 2 3
1
-1
Demux
{{-1}, {-1,-1}}

9-56

Demux

-1

Simulink Simulink Demux


Demux

Demux ( )

Number of outputs

Bus selection mode

9-57

Derivative

9Derivative

Continuous

Derivative

u
------t
u t
1 1

1
y ( k ) = ----- ( u ( k ) u ( k 1 ) )
t
z
1

Y( z)
1z
z1
---------- = ---------------- = -----------u( z)
t
t z
linmod Derivative
6-4

9-58

Derivative double

Derivative

N/A

9-59

Digital Clock

9Digital Clock

Sources

Digital Clock

( )Clock

Digital Clock double

Sample time
1

9-60

Direct Look-Up Table (n-D)

9Direct Look-Up Table (n-D)

Functions & Tables

Direct Look-Up Table (n-D) n

uint8
256

2 N

Table data
2
2

"2-D Matrix" 5
R C 2

9-61

Direct Look-Up Table (n-D)


(
)Direct Look-Up Table

4 4-D
"8-D T[k]"
1
"n-D Direct Table Lookup5"
6, 8, 12 7 9 2
10, 11 12 figure

Invalid input value: "Clip and Warn"


Output shape:
"Vector"
Table data:
int16(a)

a MATLAB 4

a = ones(20,4,5,7); L = prod(size(a));
a(1:L) = [1:L];

9-62

Direct Look-Up Table (n-D)

figure 4 3
3 4 2 20

(1 )MATLAB

a(:,1+1,1+3,1+2)
ans =
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076

9-63

Direct Look-Up Table (n-D)


1077
1078
1079
1080

Direct Look-Up Table (n-D) double, single, int8, uint8 , int16, uint16, int32
, uint32

Table data

Number of table dimensions( )


Table data
(
Explicit Number of dimensions Use one (vector) input port instead
of N ports, )
Inputs select this object from table( )
n 2

Element # of ports = # of dimensions


Column # of ports = # of dimensions - 1

9-64

Direct Look-Up Table (n-D)

2-D Matrix # of ports = # of dimension -2


MATLAB 4
(1,2,3,4)
4
(:,2,3,4) 3 2
(:,:,3,4) 2

Make table an input( )


Direct Look-Up Table (n-D) Table Data
T

Table data ( )
4 N
breakpoint set Explicit number of dimensions

Table data
Table data Number of table dimensions
MATALB
MATALB Multidimensional Arrays

Action for out of range input(


None, Warning, Error.
Real-Time Workshop "Clip and Warn" "Clip
Index" Real-Time Workshop
clipping
"Generate Error" clipping

9-65

Direct Look-Up Table (n-D)

9-66

(
2 )

(
2 )

Discrete Filter

9Discrete Filter

Discrete

Discrete Filter (Infinite Impulse Response (IIR))


(Finite Impulse Response (FIR)) Numerator
Denominator z-1

9-82 Discrete
Transfer Fcn

IIR FIR

Discrete Filter
z-1( ) Discrete
Transfer Fcn z

n n-1

Simulink
9-243 Transfer Fcn

double

Numerator
[1]

9-67

Discrete Filter
Denominator
[1 2]
Sample time

9-68

Numerator Denominator

Denominator -1

Discrete Pulse Generator

9Discrete Pulse Generator

Sources

Discrete Pulse Generator

( ) Discrete Pulse Generator


Pulse Generator
(9-175 Pulse Generator )

Discrete Pulse Generator double

9-69

Discrete Pulse Generator

Amplitude
1
Period
2
Pulse width
1
Phase delay

0
Sample time
1
Interpret vector parameters as 1-D
pulse generation

9-70

Discrete Pulse Generator

9-71

Discrete State-Space

9Discrete State-Space

Discrete

Discrete State-Space
x ( n + 1 ) = Ax ( n ) + Bu ( n )

y ( n ) = Cx ( n ) + Du ( n )
u x y

A n n n
B n m m
C r n r
D r m
n

1 1
B D C D

Simulink

9-72

Discrete State Space double

Discrete State-Space

A, B, C, D

Initial conditions
0
Sample time

D 0

9-73

Discrete-Time Integrator

9Discrete-Time Integrator

Discrete

Discrete-Time Integrator
Integrator

Discrete-Time Integrator

Forward Euler( )
Backward Euler( )Trapezoidal( ) Simulink
k y(k) x(k+1) T (
delta T)
x(0)=IC (
)
Forward Euler ( ) Forward Rectangular( )

1/s T/(z-1)

y(k) = y(k1) + T * u(k1)


x(k+1) = x(k) + T*u(k)

9-74

0:

y(0) = x(0) = IC ( )
x(1) = y(0) + T*u(0)

1:

y(1) = x(1)
x(2) = x(1) + T*u(1)

k:

y(k) = x(k)

Discrete-Time Integrator

x(k+1) = x(k) + T*u(k) ( )

1
Backward Euler Backward Rectangular( )

1/s T*z/(z-1)

y(k) = y(k1) + T * u(k).


x(k) = y(k1),
0:

y(0) = x(0) = IC ( )
x(1) = y(0)

1:

y(1) = x(1) + T*u(1)


x(2) = y(1)

k:

y(k) = x(k) + T*u(k)


x(k+1) = y(k)

1
Trapezoidal 1/s T/2*(z+1)/(z-1)
T ( )

x(k) = y(k1) + T/2 * u(k1).

0:

y(0) = x(0) = IC ( )
x(1) = y(0) + T/2 * u(0)

1:

y(1) = x(1) + T/2 * u(1)


x(2) = y(1) + T/2 * u(1)

k:

y(k) = x(k) + T/2 * u(k)


x(k+1) = y(k) + T/2 * u(k)

9-75

Discrete-Time Integrator

x(k+1) x(k) != y(k)

T ( )

0:

y(0) = x(0) = IC ( )
x(1) = y(0)

1:

x(1) = x(1) + T/2 * (u(1) + u(0))


x(2) = y(1)

k:

y(k) = x(k) + T/2 * (u(k) + u(k-1))


x(k+1) = y(k)

Initial condition
source internal Initial condition

9-76

Discrete-Time Integrator

Initial condition source


external

bounce

clutch

Simulink
Show state port

Limit output

9-77

Discrete-Time Integrator

Lower saturation limit Lower


saturation limit
Lower saturation limit Upper saturation limit

Upper saturation limit Upper


saturation limit
Show saturation port

3
1
0
-1
Limit output 3
1 1
1

External reset

9-78

Discrete-Time Integrator

rising

falling

either

level

Show state port

Discrete-Time Integrator double

9-79

Discrete-Time Integrator

Integrator method
ForwardEuler
External reset
(rising, falling, either)

Initial condition source


Initial condition (internal ) external
(external )

Initial condition
Initial condition source internal

Limit output
Lower saturation limit Upper saturation limit

Upper saturation limit


inf

9-80

Discrete-Time Integrator

Lower saturation limit


-inf
Show saturation port

Show state port

Sample time
1

1
1
1

9-81

Discrete Transfer Fcn

9Discrete Transfer Fcn

Discrete

Discrete Transfer Fcn z

n1

nm

num 0 z + num 1 z
+ + num m z
num ( z )
H ( z ) = ------------------ = -------------------------------------------------------------------------------------------------n
n

1
den ( z )
den0 z + den 1 z
+ + denn
m+1 n+1 num den
z num
den

Discrete Transfer Fcn


z Discrete Filter
z-1 ( )

Discrete Transfer Fcn


9-255 Transfer Fcn

9-82

Discrete Transfer Function double

Discrete Transfer Fcn

Numerator

[1]
Denominator
[1 0.5]
Sample time
1

Numerator Denominator

Denominator -1

9-83

Discrete Zero-Pole

9Discrete Zero-Pole

Discrete

Discrete Zero-Pole z
- -
MATLAB

( z Z 1 ) ( z Z 2 ) ( z Z m )
Z( z)
H ( z ) = K ----------- = K ----------------------------------------------------------------P(z)
( z P 1 ) ( z P 2 ) ( z P n )
Z P K
(n m)

9-276 Zero-Pole

Discrete Zero-Pole double

Zeros
[1]

9-84

Discrete Zero-Pole

Poles
[0 0.5]
Gain
1
Sample time

Poles

9-85

Display

9Display

Sinks

Display

Format
short 5
long 15
short_e 5
long_e 16
bank ( $
)
Display Floating display
Display

Floating display Simulink


5-31

Decimation n
n
1
Sample time

-1

Display

9-86

Display

Displays only one element


of input vector but indicates
there are more

Displays both elements


of input vector

Display

Format
short
Decimation
1
Floating display

Display

9-87

Display
Sample time

9-88

Dot Product

9Dot Product

Math

Dot Product 2 y
MATLAB

y = sum(conj(u1) .* u2 )

u1 u2 2

double (
)
1

Product

Dot Product double

9-89

Dot Product

9-90

Enable

9Enable

Signals & Systems

Enable Enabled
Enabled

Enable

Simulink Enabled
Enabled
( ) States when enabling
Enabled

reset ( )
held
Show output port

Enable

Enable
Enabled 8

States when enabling


Enabled

9-91

Enable
Show output port
Simulink Enable Enable

9-92

Enable

Fcn

9Fcn

Functions & Tables

Fcn C

u u u(i) i
u(1) u

(+ * /)
(== != > < >= <=) TRUE( ) 1

0
(&& || !) TRUE( ) 1

0

abs, acos, asin, atan, atan2, ceil, cos, cosh, exp, fabs, floor, hypot, ln, log, log10,
pow, power, rem, sgn, sin, sinh, sqrt, tan, and tanh.
MATLAB

( A A(1,1))
C
1 ()
2 + ( )
3 pow ( )
4 !
5 */
6 +
7 > < <= >=
8 = !=

9-93

Fcn
9 &&
10 ||

MATLAB
(:)

Math Function
(
sin)

Fcn double

Expression
C
(

9-94

First-Order Hold

9First-Order Hold

Discrete

First-Order Hold 1

fohdemo Zero-Order Hold First-Order


Hold Sine Wave
First-Order Hold

First-Order Hold double

Sample time

1 1

9-95

First-Order Hold

9-96

From

9From

Signals & Systems

From Goto
Goto
From Goto
Goto
From Goto tag Goto

Goto

Goto From
From 1 Goto

Goto From

Block1 Block2
Block1 Goto
From Block2

Block1

Block2

Block1

Goto

From

Block2

Goto From

(
)
Goto
From
7

Goto From
9-111 Goto 9-114 Goto Tag
Visibility Goto

([])
({})

9-97

From

From

Goto tag
From Goto

9-98

Goro

From File

9From File

Sources

From File

t1

t2

t final

u1 1 u1 2 u1 final

un 1 un 2 un final

m
m-1

Simulink 2 2

time values: 0 1 2 2
data points: 2 3 4 5

2 4

Simulink
To File

9-99

From File
To File To Workspace
From File To File
To Workspace


Simulation
Parameters Workspace I/O
4
From File

From File

From File double

File name

untitled.mat
Simulink MATLAB (
MATLAB pwd
)Simulink

Sample time

9-100

From File

9-101

From Workspace

9From Workspace

Sources

From Workspace MATLAB


Data
MATLAB

( 5-19
)From Workspace Data

(2 )
structure-with-time
(1 )

From Workspace Interpolate data

Interpolate data

Form output after final data value by

9-102

Interpolate

Extrapolate

On

Extrapolate

Off

SettingToZero

On

SettingToZero

Off

HoldingFinalValue

On

From Workspace

Interpolate

HoldingFinalValue

Off

CyclicRepetition

On

CyclicRepetition

Off

Simulink

time: 0 1 2 2
signal: 2 3 4 5

2 5 5

From Workspace
To Workspace ( 9-240 To Workspace
) ( 9-240 To
Workspace )To Workspace

From Workspace
double
double

9-103

From Workspace

Data

T U

[T,U]

Sample time

Interpolate data

Form output after final data value by

9-104

From Workspace

9-105

Function-Call Generator

9Function-Call Generator

Signals & Systems

Function-Call Generator Sample time


function-call ( function-call
Stateflow ) function-call
Function-Call Generator
function-call
Demux
Demux Demux
2 Demux

Function-Call double

Function-Call

Sample time

Number of iterations

9-106

Function-Call Generator

9-107

Gain

9Gain

Math

Gain
Gain

Multiplication

Gain Gain

9-221 Slider Gain

Gain

single double

Gain boolean

Gain Gain
Gain


Gain
Simulink

Simulink
uint8 -1

Simulink

Gain Saturate on integer overflow

9-108

Gain

int8 127 127


-128 -128

Multiplication

K.*u ( )
K*u ( )
u*K ( )
Gain

1Gain double
Grain
K
Saturate on integer overflow

Gain

Simulink Simulation Parameters


Diagnostics Data overflow
( 5-25 Diagnostics )

9-109

Gain

9-110

Gain

Goto

9Goto

Signals & Systems

Goto From

From Goto

From

From From 1
Goto Goto
From
From Goto
9-97 From Goto
From Tag Goto

Tag visibility From

local From Goto


local ([])

scoped From Goto


Goto Tag Visibility
scoped ({})
global From Goto

scoped Goto
Simulink
scoped Goto
Goto Tag Visibility

Goto From
local Goto
From global scoped

9-111

Goto
global
scoped
(A) 2 scoped

Goto

Tag
Goto
Goto

9-112

Goto

Tag visibility
Goto local, scoped, global
local

9-113

Goto Tag Visibility

9Goto Tag Visibility

Signals & Systems

Goto Tag Visibility scoped Goto


Goto tag
Goto Tag Visibility
From

Goto

Goto Tag Visibility Tag visibility scoped


Goto local global
({})

Goto tag
Goto

9-114

N/A

N/A

Ground

9Ground

Signals & Systems

Ground

Simulink
" " Ground
Ground

Ground ( )
.

Constant Ground
(int8) Ground

9-115

Hit Crossing

9Hit Crossing

Signals & Systems

Hit Crossing Hit crossing direction


Hit crossing offset

double 1 Show output port

1 2
(
) 2 1
Show output port

Hit crossing direction either

"Almost Equal"

hardstop clutch Hit Crossing hardstop


Hit Crossing Friction Model
clutch Hit Crossing Lockup Detection

9-116

Hit Crossing boolean ( 4-49


Boolean )boolean
double

Hit Crossing

Hit crossing offset

Hit crossing direction

Show output port

9-117

IC

9IC

Signals & Systems

IC

IC "test signal"

t = 0 3 6
IC
3-18

IC double

Initial value
1

9-118

IC

9-119

Inport

9Inport

Signals & Systems

Inport

Simulink Inport
Inport 1

Inport

Inport
Inport

Inport
Inport
Inport

Inport Port dimensions


-1 ( ) Simulink

Sample time
(-1)

Inport Inport

Inport
Inport
Subsystem
Inport
Subsystem Inport Subsystem
Port number
Port number 1

9-120

Inport

Subsystem

Inport Port number

Inport Subsystem
Inport Format
Hide Name Edit Update
Diagram

Inport
Inport 2 1
Simulation Parameters
sim

Simulation
Parameters ( 5-19
) sim ( 5-38 sim ) ut
linmod trim
Inport
Inport 5

Inport
Inport
Inport Signal type Data type
( )
Inport
Inport
Inport

Enable Trigger Inport

9-121

Inport
Outport
Enabled

In1
In2

Port number
Inport
Port dimensions
Inport -1

9-122

Inport

Sample time

Data type

Signal type
( )

3 Inport
Inport

Interpolate data

5-19

9-123

Integrator

9Integrator

Continuous

Integrator
Integrator




Discrete-Time Integrator

Initial condition source


internal Initial condition

Initial condition source


external

9-124

Integrator

bounce

clutch

Simulink
Show state port

Limit output

Lower saturation limit Lower


saturation limit
Lower saturation limit Upper saturation limit

Upper saturation limit Upper


saturation limit

9-125

Integrator
Show saturation port

3
1
0
-1
3
1 1
1

External reset
1

rising

falling

either

level

9-126

Integrator

Show state port

Integrator
Absolute tolerance

5-14

Integrator double
double boolean

9-127

Integrator

External reset
(rising, falling, either, level)

Initial condition source


Initial condition (internal )
(external )
Initial condition
Initial condition source internal

Limit output
Lower saturation limit Upper saturation limit

Upper saturation limit


inf
Lower saturation limit
-inf
Show saturation port

9-128

Integrator

Show state port

Absolute tolerance

Limit output
1
1
1

9-129

Logical Operator

9Logical Operator

Math

Logical Operator AND


ORNANDNORXOR NOT
TRUE 1 FALSE
0


2 2
2 2

(
)
AND 2 2
AND
2 2
NOT
1 1 1
2

NOT 1

XOR logic elements


IEEE 2

9-130

Logical Operator boolean


(4-49 Boolean )boolean
double
double TRUE(1) FALSE(0)

Logical Operator

Operator

Number of input ports

9-131

Look-Up Table

9Look-Up Table

Functions & Tables

Look-Up Table

Vector of input values Vector of output values (


)

2 2
2 1 Look-Up Table (2-D)
9-135 Look-Up Table (2-D)

[2 1 1 0 0 0 1 1 2]
values [1 1 2 2 1 2 2 1 1]

the output value

u = -1, 0, +1 3

9-132

Look-Up Table

u
u -1 y
-2
u
u 1 y
2
u 2
u = 0 y = 1 1
0 u = 0 2
3
1
Look-Up Table

Apply Close

Look-Up Table double

Vector of input values

9-133

Look-Up Table
Vector of output values

9-134

Look-Up Table (2-D)

9Look-Up Table (2-D)

Functions & Tables

Look-Up Table (2-D)

Table
Row Column
Row Column
2

2 2
Row Column
Look-Up Table

Look-Up Table
( 9-132 Look-Up Table )

Row: [1 2]
Column: [3 4]
Table: [10 20; 30 40]

9-135

Look-Up Table (2-D)

1 2 4
( 1) 2 ( 4)

1 10 20
2 30 40
2 1.72 3.4

(28)
3

3.4 4

1 10 14 20
1.7 24 28 34
2 30 34 40

Look-Up Table (2-D) double

Row

9-136

Look-Up Table (2-D)

Column

Table
Row Column

1 1

9-137

Look-Up Table (n-D)


9Look-Up Table (n-D)

N N

Functions & Tables

Look-Up Table (n-D) F T


N
y = F ( x1, x2, x3, , xn )

Flat ( )

Natural ( )
1 2 3

Table data N

( ) 2

9-138

Look-Up Table (n-D)

Look-Up Table(n-D) PreLook-Up Index Search

Direct Look-Up Table, (n-D)


k k y = table(k).

n-D Interpolated Look-Up Table double single


n-D Interpolated Look-Up Table
Breakpoint

9-139

Look-Up Table (n-D)


Number of table dimensions
Table data
( "Explicit Number of dimensions"
"Use one (vector) input port instead of N ports" )
First input (row) breakpoint set

Second (column) input breakpoint set

Number of table dimensions


2, 3, 4 More
Third ... Nth input breakpoint set
3
Number of table
dimensions 3, 4 More
Fourth input breakpoint set
4
Number of table
dimensions 4 More
Fifth..Nth input breakpoint sets (cell array)
1 3, 4,
{[10:10:30],
[0:10:100]} 5 6 2

Number of table dimensions More

Explicit number of dimensions


5 Numbor of table dimensions More

Index search method


"Evenly Spaced Points", "Linear Search", "Binary Search" ( )

9-140

Look-Up Table (n-D)

10, 20, 30, ...,


"Evenly Spaced Points"

"Linear Search"
"Begin index searches using previous index results"
1 2

"Binary Search" "Evenly


Spaced Points"
2
Begin index searches using previous index results

Use one (vector) input port instead of N ports


1 N
N 1

Table data
N breakpoint set
4 Explicit number of dimensions

Interpolation method
None (flat), Linear, Cubic Spline.
Extrapolation method
None (clip), Linear, Cubic Spline.
Action for out of range input
None, Warning, Error
"Warning"

9-141

Look-Up Table (n-D)


"Error"

9-142

Magnitude-Angle to Complex

9Magnitude-Angle to Complex

Math

Magnitude-Angle to Complex
double

double

( )

Input

Angle (Magnitude)

9-143

Magnitude-Angle to Complex

9-144

2 1

Manual Switch

9Manual Switch

Nonlinear

Manual Switch 2

(
)

Manual Switch

Manual Switch

( )

N/A

9-145

Math Function

9Math Function

Math

Math Function

Function exp, log, 10u,


log10, square, sqrt, pow, reciprocal, hypot, rem, mod, transpose, hermitian

Simulink

Fcn
Math Function

Math Function double


Output signal type

Function

9-146

Math Function

Output signal type


Math Function

magnitude squared

hypot, rem, mod

Exp, log, 10 , log10, square,


sqrt, pow, reciprocal,
conjugate, transpose, hermitian

9-147

MATLAB Fcn

9MATLAB Fcn

Functions & Tables

MATLAB Fcn MATLAB

MATLAB

sin
atan2(u(1), u(2))
u(1)^u(2)

MATLAB
Fcn (Fcn
Elementary Math ) M-
MEX- S- S-Function

9-148

MATLAB Fcn double


Output signal type double

MATLAB Fcn

MATLAB function

Output dimensions
-1

Output signal type


MATLAB fcn

Collapse 2-D results to 1-D


2 2 1

N/A

9-149

Matrix Gain

9Matrix Gain

Math

Matrix Gain

Gain

Gain
eye(3,3) Gain

Multiplication

Saturate on Integer Overflow


element-wise Gain

9-150

Matrix Gain

9-151

Memory

9Memory

Continuous

Memory 1

(
)
Sum
Memory

ode15s ode113
Memory

Memory (
)
0

Initial condition

Inherit sample time

9-152

Memory

Inherit sample time

Initial condition

9-153

Merge

9Merge

Signals & Systems

Merge

Merge Number of Inputs

Merge
Merge "
"

Merge

Selector 1 4
Merge Selector

Merge Allow unequal port widths Merge

Allow unequal port widths Merge

9-154

Merge

( )

max(w1+o1, w2+o2, ... wn+on)


w1, ... wn o1, ... on
Merge v3 v1 v2
v1 0v2 2
6 Merge v1 v3
2 v2 v3 4
Initial Output
Merge
Merge

Merge (
)
0

9-155

Merge

Number of inputs

Initial output

1
Allow unequal port widths

Input port offsets

9-156

MinMax

9MinMax

Math

MinMax
Function 1

MinMax double

Function
(min max)
Number of input ports

9-157

MinMax

9-158

Model Info

9Model Info

Signals & Systems

ModelInfo
vdp
Model Info

Model Info /

Model Info Model Info

9-159

Model Info

Model Info

Editable text. Model Info


%<propname>
propname

1.1
Version %<ModelVersion>

Version 1.1

Model properties Configuration manager properties

Model properties.
Editable
text Created( )

9-160

Model Info

%<Created>% Editable text


4-114


RCS properties.
( 4-110
Configuration manager )
( RCS
Properties)Model Info

Model Info

9-161

Multiport Switch

9Multiport Switch

Nonlinear

Multiport Switch

( )

Multiport Switch
( ) 1
out-of-bounds
( )
Multiport Switch
( )

Out of bound

Out of bounds

9-162

Multiport Switch boolean

Multiport Switch

Number of inputs

9-163

Mux

9Mux

Signals & Systems

Mux 1
Mux
composite Mux

(1 )
1 1
Mux
( ., Demux, Subsystem, Go To )

1 composite

Mux Number of Inputs

Mux Number of Inputs


Mux
Simulink
signalN N

[2 3] 2 3
Simulink
-1

N N
[M N] M N -1


Simulink
position,velocity

9-164

Mux

Mux position velocity 2

Simulink Simulink Mux

Mux

Number of inputs

Display option

none

Mux

signals

bar

9-165

Outport

9Outport

Signals & Systems

Outport

Simulink Outport
Outport1

Outport

Outport
Outport

Outport
Outport
Outport

Outport
Outport
Outport Subsystem
Subsystem
Outport Port number Subsystem
Port number
1 Outport Subsystem

Outport Port number


( )

Outport Simulink

9-166

Outport

Outport Subsystem
Outport
Format Hide Name

Outport
Outport Enabled

reset held Output when


disabled Initial
output reset

Outport
Outport 2 1
Simulation
Parameters sim
1

Simulation Parameters
(5-22 Saving Output to the Workspace ) sim
( 5-38 sim). Outport

[t,x,y] = sim(...);

y Outport
Outport

2 ( ) Outport
2 Outport
Outport 1 speed
Outport 2 dist

[t,x,speed,dist] = sim(...);

linmod trim
Outport 5

9-167

Outport

Outport MATLAB

Outport

outport

Simulink outport Initial output

Simulink
Simulink
Simulink

Port number
Outport
Output when disabled

Initial output

9-168

Outport

9-169

Product

9Product

Math

Product Multiplication Number of inputs

Number of inputs * /

*/

Multiplication element-wise
Multiplication element-wise *
/
n
n
y i = u1 i u2 i un i
( Dot Product

1 1 1

Multiplication matrix *
/
Number of Inputs
*/* AB-1C A, B, C 1,2,3

9-170

Product

Number of inputs * Multiplication


element-wise 1 1
1 2
y = u i

Multiplication element-wise Simulink


Multiplication matrix

Number of inputs / Multiplication


element-wise 1
Multiplication element-wise
Simulink Multiplication
matrix
Number of inputs *

Simulink

Product

single double

9-171

Product

Multiplication

Number of inputs
* / 2
Saturate on integer overflow

Product

Simulink Simulation
Parameters Diagnostics Data overflow
( 5-25 Diagnostics
)

9-172

Probe

9Probe

Signals & Systems

Probe Probe

Probe 1
(
)
Probe

double

Probe double

1 /

Probe width
( )
Probe sample time

Probe complex signal

9-173

Probe
Probe signal dimensions

9-174

Pulse Generator

9Pulse Generator

Sources

Pulse Generator
Amplitude, Period, Duty cycle, Start time

( )

Pulse Generator
Discrete Pulse Generator

Pulse Generator
( ) Amplitude

Period
1
Duty cycle
50

9-175

Pulse Generator
Amplitude
1
Start time
0
Interpret vector parameters as 1-D
1 1
1 ( )

9-176

Quantizer

9Quantizer

Nonlinear

Quantizer
1

y = q * round(u/q)

y u q Quantization interval

Quantizer single double

Quantization interval
Quantizer n*q
n q Quantization interval 0.5
Treat as gain when linearizing
Simulink Quantizer

9-177

Quantizer

9-178

Ramp

9Ramp

Sources

Ramp
SlopeStart timeDuty
CycleInitial output

Ramp double

Slope
1
Start time
0
Initial output
0
Interpret vector parameters as 1-D
1 1
1-D ( )

9-179

Ramp

9-180

Random Number

9Random Number

Sources

Random Number

0 1

Random Number

Initial seed
Uniform Random Number

Band-Limited White Noise

Random Number double

9-181

Random Number
Mean
0
Variance
1
Initial seed
0
Sample time
0

Interpret vector parameters as 1-D


1 1
1-D ( )

9-182

Rate Limiter

9Rate Limiter

Nonlinear

Rate Limiter

u(i ) y(i 1)
rate = ---------------------------------t(i) t(i 1 )
u(i) t(i) y(i1) t(i1)
rate Rising slew rate Falling slew rate

rate Rising slew rate (R )

y ( i ) = t R + y ( i 1 )
rate Falling slew rate (F )

y ( i ) = t F + y ( i 1 )
rate R F

y(i) = u(i )

Rate Limiter double

Rising slew rate

9-183

Rate Limiter
Falling slew rate

9-184

Real-Imag to Complex

9Real-Imag to Complex

Math

Real-Imag to Complex

( )
1

( )

double
double

Input

9-185

Real-Imag to Complex
Real (Imag) part

9-186

Relational Operator

9Relational Operator

Math

Relational Operator 2

==

2 TRUE

~=

2 TRUE

<

2 TRUE

<=

2 TRUE

>=

2 TRUE

>

2 TRUE

TRUE 1 FALSE 0

Relational Operator

== != 1
boolean ( 4-49
Boolean )boolean
double

9-187

Relational Operator

Operator

9-188

Relay

9Relay

Nonlinear

Relay 2
Switch off point
Switch on point
1 1

Switch off point Switch on point

Switch on point Switch off point

Relay double

Switch on point
eps
Switch off point
eps
Output when on
1

9-189

Relay
Output when off
0

9-190

Repeating Sequence

9Repeating Sequence

Sources

Repeating Sequence

Time valuesOutput values Times value


Output values

( )
1 Time values Output values
[0 2]
2 2
Repeating Sequence

1 Look-Up Table

Repeating Sequence double

Time values
[0 2]

9-191

Repeating Sequence
Output values
[0
2]

9-192

Reshape

9Reshape

Signals & Systems

Reshape Output dimensionality

N- 1xN Nx1

Output dimensionality

Output
Dimensionality

(2 ) (1 )
1
2 (
)

Mx1
M

1xN
N

Output dimensions
Output dimensions
1 2
[N] N [M N]
MxN Output
dimensions

9-193

Reshape

Reshape

Output dimensionality

Output dimensions
Output
dimensionality Customize

9-194

N/A

Rounding Function

9Rounding Function

Math

Rounding Function

Function 1
Function floor, ceil, round, fix
Rounding Function
double

Fcn Rounding
Function Fcn

Rounding Function double

Function

N/A

9-195

Saturation

9Saturation

Nonlinear

Saturation Lower limit


Upper limit

Saturation

Upper limit

Lower limit

9-196

Saturation

9-197

Scope

9Scope

Sinks

Scope
Scope ( 1 )
y-
Scope
Scope
Scope

Simulink Scope
Scope
Scope Scope (1 )
Scope
Scope
Scope Scope

Scope
Scope

x-y
x
y
Auto-Scale

9-198

Scope

Scope
scope

Scope

6 Scope


Properties....

Y-min
y
Y-max
y
Title
%<SignalLabel>
(%<SignalLabel>

9-199

Scope
Time Offset
vdp Scope
40 Scope
20 Time offset
0 x

9-200

Scope

Scope
Auto-scale

y
y

Auto-scale

Auto-scale

x y

Zoom

Scope

Scope y x-y
x-y x x-y
x-y x

9-201

Scope

x Zoom

9-202

Scope

Scope

Scope

y Zoom
x

Save axes settings x y

Save axes settings

Scope

Properties

Properties

9-203

Scope
Properties

General Data history

General
General
floating scope
Number of axes

Scope
x y
y

Time range
Time range auto x

auto
x

Tick labels
Tick labels
bottom axis

9-204

Scope

Floating scope
Scope Floating scope
Scope
Scope
Scope Scope

Properties General
Floating scope
Scope Scope

Shift

Scope Auto-scale data

Scope Signal Selector(9-217 Signal Selector )


Signal Selector

1
1

Scope

5-31

Sampling
Decimation

Sample time

9-205

Scope

Data History Scope

Apply OK

Limit data points to last


Limit rows to last

Scope
1000
2000 1000

Save data to workspace


Save data to workspace Scope

Variable name Format

Variable name
Variable name

Scope To Workspace

9-206

Scope

Scope
Scope To Workspace

Format
3
Matrix, Structure, Structure with time
Scope Matrix
Scope
Structure Structure
with time

Scope
Scope Scope
Print Scope Properties
Print icon

Scope

9-207

Selector

9Selector

Signals & Systems

Selector

Slector
Input
Type ( )

Selector
Elements
Source of element indices
(internal external) external

1
Selector [2 4 6
8 10] Elements [5 1 3]

external
Elements

Input port width


-1 0

9-208

Selector

-1

Selector
Rows Columns

Source of row indices Source of column indices (internal


external) external
external
2
( 1
1 ) Rows [2 1]
Columns [1 3] 2
2 1 3
1 3

Selector

9-209

Selector

Input Type
:
Source of element indices
internal Elements
external
Elements

Input port width

9-210

Selector

Input Type
:
Source of row indices
internal
Rows external
Rows

Source of column indices


internal
Columns external
Columns

9-211

S-Function

9S-Function

Functions & Tables

S-Function S-
S-function name S- S M- MEX-

S-

S-Function S-
MATLAB

A, B, C, D, [eye(2,2);zeros(2,2)]

S-Function S-
1 1

S-
S-
S-
2 2
S-

9-212

S-Function

S-Function

S-function name
S-function
S-function parameters
S-function

S-function

S-function

S-function

S-function

9-213

Sign

9Sign

Math

Sign

1
0
-1

double

Dialog Box

9-214

N/A

Signal Generator

9Signal Generator

Sources

Signal Generator 3 1
( )
/
Scope

Sine Wave

Square Wave

Sawtooth Wave
Amplitude 180 180
Clock MATLAB Fcn

9-215

Signal Generator
Signal Generator

Amplitude Frequency

Interpret vector parameters as 1-D (


)Amplitude Frequency
Interpret vector parameters as 1-D Amplitude
Frequency
2 1 (1 )

Signal Generator double

Wave form

Amplitude
1
Frequency
1
Units
/

9-216

Signal Generator

Interpret vector parameters as 1-D


Amplitude Frequency

9-217

Sine Wave

9Sine Wave

Sources

Sine Wave

Sine Wave
y = Amplitude sin ( frequency time + phase )
Sample time

0 ( )
>0
-1

Sine Wave
Sample time
Zero-Order Hold

Sine Wave /

Sine Wave

sin ( t + t ) = sin ( t ) cos ( t ) + sin ( t ) cos ( t )


cos ( t + t ) = cos ( t ) cos ( t ) sin ( t ) sin ( t )

9-218

Sine Wave

sin ( t + t ) = cos ( t ) sin ( t ) sin ( t )


cos ( t + t )
sin ( t ) cos ( t ) cos ( t )
t
cos ( t ) sin ( t )
sin ( t ) cos ( t )
sin(t) sin(t+t)
1

Sine Wave
Sample time

Sine Wave

Interpret vector parameters as 1-D


Interpret vector parameters as 1-D
( 2
) 1 (1 )

Sine Wave double

9-219

Sine Wave

Amplitude
1
Frequency
/ 1 /
Phase
0
Sample time
0
Interpret vector parameters as 1-D
Sine Wave

9-220

Slider Gain

9Slider Gain

Math

Slider Gain
1 1

Slider Gain Gain


( 9-108 Gain )

Low
0
High
2
( )
2

Close

1%
10%
Gain

9-221

Slider Gain

9-222

State-Space

9State-Space

Continuous

State-Space

x = Ax + Bu
y = Cx + Du
x u y

A n n n
B n m m
C r n r
D r m
n

1 1
B D C D

Simulink

A State-Space double

9-223

State-Space

A, B, C, D

Initial conditions

9-224

D 0

Step

9Step

Sources

Step 2
Step time
Initial value Step
time Final value

Step

Interpret vector parameters as 1-D


Interpret vector parameters
as 1-D (
2 ) 1 (1 )

Step double

Step time
Initial value Final value
1

9-225

Step
Initial value
Step time
0
Final value
Step time
1

Interpret vector parameters as 1-D


Step 1

9-226

Stop Simulation

9Stop Simulation

Sinks

Stop Simulation

Relational Operator

10

Stop Simulation double boolean

9-227

Subsystem

9Subsystem

Signals & Systems

Subsystem 1

Subsystem Signals & Systems


Subsystem

()
Edit
Create Subsystem Simulink Subsystem

Inport Outport

Subsystem
Inport
Outport
3 Subsystems

9-228

Subsystem enable trigger


9-120
Inport
9-166 Outport

Subsystem

Show port labels

Treat as atomic unit


Simulink 1

Simulink

Simulink

3-13 Atomic

9-229

Subsystem
Access

ReadWrite

ReadOnly

NoReadOrWrite

Name of error callback function


Simulink
2
Simulink

RTW Real-Time Workshop


Real-Time Workshop

9-230

Subsystem

9-231

Sum

9Sum

Math

Sum

2 2
2 2

2 2 2
2
( )

Simulink Sum Simulink

9-232

Sum

Sum

Icon shape
Icon shape Sum
Sum

List of signs
List of signs -
Simulink
-

Sum + - List of signs

Simulink
List of signs |
|
++|-- 2 + -

Saturate on integer overflow


Sum

Simulink Simulation Parameters Diagnostics

9-233

Sum
Data overflow ( 5-25
Diagnostics )

9-234

Switch

9Switch

Nonlinear

Switch 3 2 1
(2 ) Threshold
3

( 0 1) 0.5

Switch ( 1 3)

Switch

Threshold bool double

Threshold
(2 )

9-235

Switch

9-236

Terminator

9Terminator

Signals & Systems

Terminator

Simulink
Terminator

Terminator

9-237

To File

9To File

Sinks

To File MAT-
1

t1

t2

t final

u1 1 u1 2 u1 final

un 1 un 2 un final
From File To File
From Workspace
To File

Decimation n
n 1

Sample time

-1

9-238

To File double

To File

Filename
MAT-
Variable name

Decimation
1
Sample time

9-239

To Workspace

9To Workspace

Sinks

To Workspace
Variable name
Save format

Array
To Workspace N-
N 1
1 ( )
2 2 ( ) 3

simout
simout(1,:) simout(2,:) 2
3

simout simout(:,:,1)
simout(:,:,2) 2

Limit data points to last

inf
Decimation n
n 1

Sample time

-1

9-240

To Workspace

Structure
3 blockName
blockName To Workspace
2

Structure with Time

Structure

From Workspace
From Workspace
" "
Structure with Time

0Maximum number of sample points i 100Decimation 1Sample


time 0.5 To Workspace 0, 0.5, 1.0,
1.5... 100 Decimation 1

Maximum number of sample points 100Sample time 0.5


Decimation 5 0, 2.5, 5.0, 7.5...
100 Decimation 5 5

Limit data points to last 3


3
100
99.0 99.5 100.0 (3 )

9-241

To Workspace

To Workspace MATLAB

Variable name

Limit data points to last


( 1 )
1000
Decimation
1
Sample time

Save format

9-242

Transfer Fcn

9Transfer Fcn

Continuous

Transfer Fcn (u) (y)

nn 1

nn 2

y(s)
num ( s )
num ( 1 )s
+ num ( 2 )s
+ + num ( nn )
H ( s ) = ---------- = ------------------ = -------------------------------------------------------------------------------------------------------------------nd 1
nd 2
u(s)
den ( s )
den ( 1 )s
+ den ( 2 )s
+ + den ( nd )
nn nd num den s
num
den

Transfer Fcn

tf2ss State-Space
tf2ss ABCD
help tf2ss Control System Toolbox Users Guide

Transfer Fcn
Transfer Fcn


s
Numerator [3,2,1]
Denominator ((den)) ( (den) [7,5,3,1])

9-243

Transfer Fcn
"(s)"
Numerator numDenominator den

Transfer Fcn double

Numerator

[1]
Denominator
[1 1]

9-244

Numerator Denominator

Denominator -1

Transfer Fcn

9-245

Transport Delay

9Transport Delay

Continuous

Transport Delay

Time delay
Initial input
Time delay

Initial buffer size

Simulink

1
t = 5 0.5
t = 4.5
t=4
Transport Delay t - tdelay

Unit Delay

linmod Transport Delay


5 " "

9-246

Transport Delay double

Transport Delay

Time delay

Initial input
Time delay
Initial buffer size

Pade order (for linearization)


0
n
n

Initial buffer size

9-247

Trigger

9Trigger

Signals & Systems

Trigger Triggered
Triggered
( )
1 Trigger 1
Triggered 7

Trigger type

rising (
)
falling
(
)
either

function-call S-function
( 7 "Function-Call "
)
Show output port

1
-1
0

9-248

Trigger

Trigger

Trigger type

Show output port


Simulink Trigger

Output data type


(double int8) auto
Simulink
double int8
Simulink

9-249

Trigonometric Function

9Trigonometric Function

Math

Trigonometric Function

Function Function
sin, cos, tan, asin, acos, atan, atan2, sinh, cosh, tanh
Trigonometric Function

Simulink
Trigonometric Function
double
Fcn
Trigonometric Function

Trigonometric Function double

Function

Output signal type


( )

9-250

Trigonometric Function

9-251

Uniform Random Number

9Uniform Random Number

Sources

Uniform Random Number

Uniform Random Number


Random Number

Band-Limited White Noise

Interpret vector parameters as 1-D


Interpret vector parameters as 1-D
(
2 ) 1 (1 )

9-252

Uniform Random Number double

Uniform Random Number

Minimum
-1
Maximum
1
Initial seed
0
Sample time
0
Interpret vector parameters as 1-D
Step

9-253

Unit Delay

9Unit Delay

Discrete

Unit Delay 1

z-1

Zero-Order Hold
1 Discrete Transfer Fcn
(Unit Delay Transport Delay
)

Unit Delay

Initial condition
Unit Delay

0
Sample time
1

9-254

Initial condition

Unit Delay

9-255

Variable Transport Delay

9Variable Transport Delay

Continuous

Variable Transport Delay

2
2

Maximum delay
Maximum delay

Initial input

1 t = 5
0.5 t = 4.5
t = 4
Variable Transport Delay
t - tdelay

9-256

Variable Transport Delay

Variable Transport Delay double

Maximum delay
10
Initial input

0
Buffer size
1024
Pade order (for linearization)
0
n
n transport delay

(2 )

Buffer size

9-257

Variable Transport Delay

9-258

Width

9Width

Signals & Systems

Width

Width

Width double

9-259

XY Graph

9XY Graph

Sinks

XY Graph MATLAB Figure X-Y

MATLAB Figure X-Y

2 (x )
2 (y )
2

Simulink XY Graph
Figure
XY Graph
lorenzs

XY Graph double

x-min
x -1

9-260

XY Graph

x-max
x 1
y-min
y -1
y-max
y 1
Sample time
-1

9-261

Zero-Order Hold

9Zero-Order Hold

Discrete

Zero-Order Hold
1 1

Zero-Order Hold 1

Quantizer
A/D

A Zero-Order Hold

Sample time
1

9-262

States

Zero-Pole

9Zero-Pole

Continuous

Zero-Pole Laplace s

- -
MATLAB
Z( s)
( s Z ( 1 ) ) ( s Z ( 2 ) ) ( s Z ( m ) )
H ( s ) = K ----------- = K ---------------------------------------------------------------------------------P(x)
( s P ( 1 ) ) ( s P ( 2 ) ) ( s P ( n ) )
Z P K Z
P K
Z

Zero-Pole
Zero-Pole

Zeros [3,2,1]Poles (poles)( poles


[7,5,3,1] )Gain gain


"(s)" Zeros zerosPoles polesGain
gain

9-263

Zero-Pole

Zero-Pole double

Zeros
[1]
Poles
[0 -1]
Gain
[1]

9-264

Poles Zeros

Poles

10

. . . . . . . . . . . . . . . .
. . .
Simulink
add_block . . . . . . . . . . . . . . . .
add_line . . . . . . . . . . . . . . . . .
bdclose . . . . . . . . . . . . . . . . .
bdroot . . . . . . . . . . . . . . . . .
close_system . . . . . . . . . . . . . . .
delete_block . . . . . . . . . . . . . . .
delete_line . . . . . . . . . . . . . . . .
find_system . . . . . . . . . . . . . . .
gcb . . . . . . . . . . . . . . . . . . .
gcbh . . . . . . . . . . . . . . . . . .
gcs . . . . . . . . . . . . . . . . . . .
get_param . . . . . . . . . . . . . . . .
new_system . . . . . . . . . . . . . . .
open_system . . . . . . . . . . . . . . .
replace_block . . . . . . . . . . . . . .
save_system . . . . . . . . . . . . . . .
set_param . . . . . . . . . . . . . . . .
simulink . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.10-2
10-3
10-3
10-4
10-5
10-6
10-7
10-8
10-10
10-11
10-12
10-17
10-18
10-19
10-20
10-22
10-23
10-24
10-26
10-27
10-29

10

10-2

Simulink

new_system

open_system

close_system, bdclose

save_system

find_system

add_block

delete_block

replace_block

add_line

delete_line

get_param

set_param

gcb

gcs

gcbh

Simulink

bdroot

Simulink

simulink

Simulink
Simulink

mdl

system

system/subsystem1/.../subsystem

system/subsystem1/.../subsystem/block

sprintf('\n')
cr
Signal Generator Amplitude

cr = sprintf(\n);
get_param([untitled/Signal,cr,Generator],Amplitude)
ans =
1

(/)
mymodel Signal/
Noise Location

get_param(mymodel/Signal//Noise,Location)

10-3

add_block

Simulink

add_block(src, dest)
add_block(src, dest, parameter1, value1, ...)

add_block(src, dest) src dest

built-in Simulink
( Simulink
)
add_block(src, dest_obj, parameter1, value1, ...)

Scope simulink Sinks


engine timing Scope1

add_block(simulink/Sinks/Scope, engine/timing/Scope1)

F14 controller

add_block(built-in/SubSystem, F14/controller)

Gain mymodel Volume


Gain 4
add_block(built-in/Gain, mymodel/Volume, Gain, 4)

delete_block, set_param

10add_block

10

10-4

add_line

10add_line

h = add_line(sys, oport, iport)


h = add_line(sys, points)

add_line
2

Simulink



add_line('sys', 'oport', 'iport')
'oport' 'iport' 'oport' 'iport'
'block/port'

'Gain/1' 'Sum/2' EnableTrigger


State 'subsystem_name/Enable''subsystem_name/Trigger' 'Integrator/
State'
add_line(system, points)
points x y

Sine Wave Mux


mymodel
add_line(mymodel,Sine Wave/1,Mux/1)

(20,55) (40,10)(60,60) mymodel

add_line(mymodel,[20 55; 40 10; 60 60])

delete_line

10-5

bdclose
10bdclose

10

Simulink

bdclose
bdclose(sys)
bdclose(all)

bdclose

bdclose(sys)
bdclose(all)

vdp
bdclose(vdp)

10-6

close_system, new_system, open_system, save_system

bdroot

10bdroot

bdroot
bdroot(obj)

bdroot

Simulink

bdroot(obj) obj

bdroot(gcb)

find_system, gcb

10-7

close_system

10close_system

close_system
close_system(sys)
close_system(sys, saveflag)
close_system(sys, newname)
close_system(blk)

close_system

close_system

gcs

Simulink

close_system(sys)

close_system(sys, saveflag)

saveflag 0
saveflag 1
close_system(sys, newname)

close_system(blk) 'blk'
CloseFcn

close_system

vdp
close_system(vdp)

engine

close_system(engine, 1)

10-8

close_system

mymdl12 testsys

close_system(mymdl12, testsys)

engine Combustion Unit


Delay
close_system(engine/Combustion/Unit Delay)

bdclose, gcs, new_system, open_system, save_system

10-9

delete_block

10delete_block

delete_block(blk)

delete_block(blk) blk

Simulink

vdp Out1
delete_block(vdp/Out1)

10-10

add_block

delete_line

10delete_line

delete_line(sys, oport, iport)

delete_line(sys, oport, iport) oport


iport oport iport
block/port
Gain/1 Sum/2
EnableTrigger State
subsystem_name/Enablesubsystem_name/TriggerIntegrator/State

delete_line(sys, [x y]) (x,y) 1

Sum Mux 2
mymodel
delete_line(mymodel,Sum/1,Mux/2)

add_line

10-11

find_system

10find_system

find_system(sys, c1, cv1, c2, cv2,...p1, v1, p2, v2,...)

find_system(sys, c1, cv1, c2, cv2,...p1, v1, p2, v2,...) sys


c1, c2
v1, v2
sys (
) ( )
sys
find_system
sys
find_system
sys find_system

( CaseSensitive
)
A

10-12

SearchDepth

(0 --
1 --

2 --

LookUnderMasks

none

find_system

{graphical}

functional

all

FollowLinks

on| {off}

on

off

FindAll

on| {off}

on

off
find_system
on sys

CaseSensitive

{on}| off

on

on

RegExp

on| {off}

on

off

constraint
find_system

find_system

10-13

find_system

open_bd = find_system(type, block_diagram)

clutch Unlocked
Goto
find_system(clutch/Unlocked,SearchDepth,1,BlockType,Goto)

Gain 1 vdp
Gain
gb = find_system(vdp, BlockType, Gain)
find_system(gb, Gain, 1)

find_system(vdp, BlockType, Gain, Gain, 1)

vdp

sys = get_param(vdp, Handle);


l = find_system(sys, FindAll, on, type, line);
a = find_system(sys, FindAll, on, type, annotation);

RegExp on find_system

(.)

find_system

find_subystem

10-14

find_system

a. aa, ab,
ac

0
ab* a, ab, abb
.*

1
ab+ ab, abb

^a.* a

.*a$ a

" "
\\ \

[]

1
f[oa]r for far

(-)
[a-zA-Z1-9]
circumflex (^)
f[^i]r far for
fir

\w

( [a-z_A-Z0-9]
)^\w mu
&mu

\d

([0-9] )\d+

\D

([^0-9] )

10-15

find_system

\s

([ \t\r\n\f] )

\S

([^ \t\r\n\f] )

\<WORD\>

WORD WORD

\<to\> to today

Simulink regexp
find_system on

Simulink clutch
inport outport
find_system(clutch, regexp, on, blocktype, port)

10-16

get_param, set_param

gcb

10gcb

gcb
gcb(sys)

gcb

Simulink

gcb(sys)


S-Function
MATLAB S-Function

MaskInitialization

gcb
ans =
clutch/Locked/Inertia

Gain
get_param(gcb,Gain)
ans =
1/(Iv+Ie)

gcbh, gcs

10-17

gcbh

10gcbh

gcbh

gcbh

gcbh
ans =
281.0001

10-18

gcb

gcs

10gcs

gcs

gcs

S-Function
S-Function

MaskInitialization

bdroot

gcs
ans =
clutch/Locked

gcb, bdroot

10-19

get_param

10get_param

get_param(obj, parameter)
get_param( { objects }, parameter)
get_param(handle, parameter)
get_param('obj', ObjectParameters)
get_param('obj', 'DialogParameters')

get_param(obj, parameter) obj

get_param( { objects }, parameter)

get_param(handle, parameter) handle

get_param(obj, ObjectParameters) obj

Name Name
Name,Type,Attributes
3 3
"Gain"

get_param(obj, DialogParameters)

clutch Requisite Friction


Inertia Gain
get_param(clutch/Requisite Friction/Inertia,Gain)
ans =
1/(Iv+Ie)

10-20

get_param

73
mx+b ( )

blks = find_system(gcs, Type, block);


listblks = get_param(blks, BlockType)
listblks =
SubSystem
Inport
Constant
Gain
Sum
Outport

get_param(gcb, Name)

Name

p = get_param(gcb, ObjectParameters);
a = p.Name.Attributes
ans =
read-write always-save

Sine Wave
p = get_param(untitled/Sine Wave, DialogParameters)
p=
Amplitude
Frequency
Phase
SampleTime

find_system, set_param

10-21

new_system

10new_system

new_system(sys)

new_system(sys) sys

new_system

Simulink

'mysys'
new_system(mysys)

vdp 'mysys'

new_system(vdp/mysys)

10-22

close_system, open_system, save_system

open_system

10open_system

open_system(sys)
open_system(blk)
open_system(blk, force)

Simulink

open_system(sys)

open_system(blk) blk
OpenFcn

open_system(blk, force) blk

Look Under Mask

controller

open_system(controller)

controller Gain

open_system(controller/Gain)

close_system, new_system, save_system

10-23

replace_block

10replace_block

replace_block(sys, blk1, blk2, noprompt)


replace_block(sys, Parameter, value, blk, ...)

replace_block(sys, blk1, blk2) blk1


sys blk2 blk2 Simulink
blk
noprompt
Simulink
noprompt

Simulink

replace_block(sys, Parameter, value, ..., blk)


sys blk

f14 Gain Integrator


RepNames
Simulink

RepNames = replace_block(f14,Gain,Integrator)

clutch Unlocked Gain bv


Integrator Simulink

replace_block(clutch/Unlocked,Gain,bv,Integrator)

f14 Gain Integrator

replace_block(f14,Gain,Integrator,noprompt)

10-24

replace_block

find_system, set_param

10-25

save_system

10save_system

save_system
save_system(sys)
save_system(sys, newname)

save_system

Simulink

save_system(sys)

save_system(sys, newname)

save_system

vdp
save_system(vdp)

vdp myvdp
save_system(vdp, myvdp)

10-26

close_system, new_system, open_system

set_param

10set_param

set_param(obj, parameter1, value1, parameter2, value2, ...)

set_param(obj, parameter1, value1, parameter2, value2, ...) obj

Simulink

Edit Update Diagram


2 Position
UserData

vdp Solver StopTime

set_param(vdp, Solver, ode15s, StopTime, 3000)

vdp Mu Gain 1000( )

set_param(vdp/Mu, Gain, 1000)

vdp Fcn
set_param(vdp/Fcn, Position, [50 100 110 120])

mymodel Zero-Pole Zeros


Poles
set_param(mymodel/Zero-Pole,Zeros,[2 4],Poles,[1 2 3])

Gain
k Gain

10-27

set_param
set_param(mymodel/Subsystem, k, 10)

mymodel Compute
OpenFcn my_open_fcn
Compute 4
71
set_param(mymodel/Compute, OpenFcn, my_open_fcn)

10-28

get_param, find_system

simulink

10simulink

simulink

Microsoft Windows simulink Simulink


( )UNIX Simulink

Simulink

10-29

simulink

10-30

11
Simulink

. . . . . . . . . . . . . . . . . . . . . .11-3

. . . . . . . . . . . . . . . . . . .11-4
. . . . . . .11-6

. . . . . . . . . . . . . . . . . . . . .11-7

. . . . . . . . . . . . . . . . . . .11-8
. . . . . . . . . . . . . . . . . . 11-11
. . . . . . . . . . . . 11-16
. . . . . . . . . . . . . . . . . 11-20
. . . . . . . . . . . . . . . 11-24

11 Simulink

Simulink Simulink

Simulink

11-2

Tools
Debugger

sldebug
sim
(sim 5-38 sim )

sim(vdp,[0,10],simset(debug,on))

sldebug 'vdp

Simulink vdp

GUI

114

11-3

11 Simulink

Start/Continue

Start/Continue button

First block to
be executed.

MATLAB

11-4

GUI

( 116
)

GUI
MATLAB

11-5

11 Simulink

MATLAB

1124
MATLAB (Return )

Simulink
s:b s
b
0:1
0 1 slist
(11-43
slist )

MATLAB
sldebug MATLAB
tout yout

(sldebug ...) plot(tout, yout)

sldebug
s step
sldebug s

(sldebug...) eval(s)

11-6

Help
F1
Help

Help button

MATLAB F1

help

11-7

11 Simulink

Simulink


(1111 )


GUI

Next BlockNext Time Step

Start/ContinueStop

...

step

next

continue

run

GUI
Run/Continue
Run/Continue continue

11-8

( 1111 )

run

MATLAB

step
( 1120
)
vdp

(U) (Y)
(GUI
) MATLAB ( )

(sldebug @0:0 vdp/Integrator1): step


U1 = [0]

11-9

11 Simulink

Y1 = [2]
(sldebug @0:1 vdp/Out1):

GUI
MATLAB vdp

MATLAB
(sldebug @0:8 vdp/Sum): step
U1 = [2]
U2 = [0]
Y1 = [-2]
[Tm=0.0001004754572603832 ] **Start** of system vdp outputs

Break on conditions Minor time steps


minor

next

vdp next MATLAB

[Tm=0.0001004754572603832 ] **Start** of system vdp outputs

11-10

Simulink

continue
2

continue

Breakpoint

(GUI )

...

break <gcb | s:b>

bafter <gcb | s:b>

11-11

11 Simulink

...

tbreak [t]

nanbreak

(NaN)
(Inf)

xbreak

zcbreak

break gcb

( )
break s:b

s:b ( 116
)

11-12

slist
(1121 )

GUI Watch points

bafter
break

Watch points (GUI


)
GUI Watch points
Remove watch point
clear

clear gcb

11-13

11 Simulink

Stop at time
(GUI ) tbreak

vdp

tbreak 9
continue

continue 9.0785

[Tm=9.07847133212036

] **Start** of system vdp outputs

NaN values nanbreak

Simulink

Step size limited by state xbreak

Zero crossings zcbreak

Simulink (rising
falling) zeroxing

sldebug zeroxing
[Tm=0
] **Start** of system zeroxing outputs
(sldebug @0:0 zeroxing/Sine Wave): zcbreak

11-14

Break at zero crossing events is enabled.

(sldebug @0:0 zeroxing/Sine Wave): continue

rising
[Tm=0.34350110879329

] Breaking at block 0:2

[Tm=0.34350110879329
Saturation

] Rising zero crossing on 3rd zcsignal in block 0:2 zeroxing/

11-15

11 Simulink

Simulink

I/O

I/O
Watch Block I/O Display Block I/O

I/O ...

probe

disp

trace

I/O
I/O GUI

probe

11-16

probe

probe probe

probe

probe gcb

I/O

probe s:b

s b
I/O

(GUI ) MATLAB

probe I/O I/O


step

probe I/O

next next I/O


next I/O
probe

I/O
disp

disp gcb
undisp
block 0:0
undisp gcb undisp 0:0

I/O GUI

disp
I/O disp

I/O step
I/
O I/O
disp

11-17

11 Simulink

I/O

trace GUI
Watch points watch

trace
untrace

I/O

I/O

atrace
( 318 )

atrace 0

atrace 1

atrace 2

atrace 3

atrace 4

states MATLAB
Simulink
(bounce) 1 2

11-18

sldebug bounce
[Tm=0
] **Start** of system bounce outputs
(sldebug @0:0 bounce/Position): states
Continuous state vector (value,index,name):
10
0 (0:0 bounce/Position)
15
1 (0:5 bounce/Velocity)
(sldebug @0:0 bounce/Position): next
[Tm=0.01
] **Start** of system bounce outputs
(sldebug @0:0 bounce/Position): states
Continuous state vector (value,index,name):
10.1495095
0 (0:0 bounce/Position)
14.9019
1 (0:5 bounce/Velocity)

ishow

[Tm=9.996264188473381

] Step of 0.01 was taken by integrator

[Ts=9.676264188473388

] Integration limited by 1st state of block 0:0 bounce/Position

11-19

11 Simulink

Simulink
Simulink
" "
GUI Execution Order
slist
MATLAB

---- Sorted list for vdp [12 blocks, 9 nonvirtual blocks, directFeed=0]
0:0 vdp/Integrator1 (Integrator)
0:1 vdp/Out1 (Outport)
0:2 vdp/Integrator2 (Integrator)
0:3 vdp/Out2 (Outport)
0:4 vdp/Fcn (Fcn)
0:5 vdp/Product (Product)
0:6 vdp/Mu (Gain)
0:7 vdp/Scope (Scope)
0:8 vdp/Sum (Sum)

bshow s:b s:b


bshow ( )

systems
Simulink clutch (clutch)

sldebug clutch
[Tm=0
] **Start** of system clutch outputs
(sldebug @0:0 clutch/Clutch Pedal): systems

11-20

0 clutch
1 clutch/Locked
2 clutch/Unlocked

systems

Simulink
Simulink

( )
systems

slist

Van der Pol (vdp)

sldebug vdp
[Tm=0
] **Start** of system vdp outputs
(sldebug @0:0 vdp/Integrator1): slist
---- Sorted list for vdp [12 blocks, 9 nonvirtual blocks, directFeed=0]
0:0 vdp/Integrator1 (Integrator)
0:1 vdp/Out1 (Outport)
0:2 vdp/Integrator2 (Integrator)
0:3 vdp/Out2 (Outport)
0:4 vdp/Fcn (Fcn)
0:5 vdp/Product (Product)
0:6 vdp/Mu (Gain)
0:7 vdp/Scope (Scope)
0:8 vdp/Sum (Sum)

slist

11-21

11 Simulink

zclist
zclist clutch

(sldebug @0:0 clutch/Clutch Pedal): zclist


2:3 clutch/Unlocked/Sign (Signum)
0:4 clutch/Lockup Detection/Velocities Match (HitCross)
0:10 clutch/Lockup Detection/Required Friction
for Lockup/Abs (Abs)
0:11 clutch/Lockup Detection/Required Friction for
Lockup/ Relational Operator (RelationalOperator)
0:18 clutch/Break Apart Detection/Abs (Abs)
0:20 clutch/Break Apart Detection/Relational Operator
(RelationalOperator)
0:24 clutch/Unlocked (SubSystem)
0:27 clutch/Locked (SubSystem)

ashow
ashow s#n,
s ( 1120
) n
ashow
gcb ashow s:b
s:b
ashow clear

GUI
Status
status
vdp
sim(vdp,[0,10],simset(debug,on))
[Tm=0
] **Start** of system vdp outputs
(sldebug @0:0 vdp/Integrator1): status
Current simulation time: 0 (MajorTimeStep)
Last command: ""
Stop in minor times steps is disabled.

11-22

Break at zero crossing events is disabled.


Break when step size is limiting by a state is disabled.
Break on non-finite (NaN,Inf) values is disabled.
Display of integration information is disabled.
Algebraic loop tracing level is at 0.

11-23

11 Simulink

Repeat
Return

11-24

ashow

as

atrace

at

bafter

ba

break

bshow

bs

clear

cl

continue

disp

I/O

help

? or h

ishow

minor

nanbreak

na

next

probe

1 I/O

quit

run

slist

sli

states

state

status

stat

step

stop

sto

systems

sys

tbreak

tb

trace

tr

I/O

undisp

und

untrace

unt

xbreak

11-25

11 Simulink

11-26

zcbreak

zcb

zclist

zcl

ashow

11ashow

ashow <gcb | s:b | s#n | clear>

s:b

s b

gcb

s#n

s n

clear

ashow gcb ashow s:b


ashow s#n s n
ashow clear

atrace, slist

11-27

atrace

11atrace

atrace level

level

atrace

11-28

(0 = 4 = )

atrace 0

atrace 1

atrace 2

atrace 3

atrace 4

systems, states

bafter

11bafter

bafter gcb
bafter s:b

s:b

s b

gcb

bafter

break, xbreak, tbreak, nanbreak, zcbreak, slist

11-29

break

11break

break gcb
break s:b

s:b

s b

gcb

break

bafter, tbreak, xbreak, nanbreak, zcbreak, slist

11-30

bshow

11bshow

bshow s:b

s:b

slist

s b

11-31

clear

11clear

clear gcb
clear s:b

s:b

s b

gcb

clear

bafter, slist

11-32

continue

11continue

continue

continue

run, stop, quit

11-33

disp

11disp

disp gcb
disp s:b
disp

s:b

s b

gcb

I/O

disp 1
MATLAB
disp

undisp

undisp, slist, probe, trace

11-34

help

11help

help

help

11-35

ishow

11ishow

ishow

ishow

atrace

11-36

minor

11minor

minor

minor

step

step
step

step

11-37

nanbreak

11nanbreak

nanbreak

nanbreak (NaN Inf)

nanbreak

break, bafter, xbreak, tbreak, zcbreak

11-38

next

11next

next

next
next

step

11-39

probe

11probe

probe [<s:b | gcb>] [level io | (all)]

s:b

s b

gcb

level io

I/O

level all

probe probe /
probe I/O
probe probe gcb
I/O probe s:b
s:b I/O

disp, trace

11-40

quit

11quit

quit

quit

stop

11-41

run

11run

run

run
run

continue, stop, quit

11-42

slist

11slist

slist

slist

systems

11-43

states

11states

states

states

ishow

11-44

systems

11systems

systems

systems MATLAB

slist

11-45

status

11status

status

status

11-46

step

11step

step

step
step

next

11-47

stop

11stop

stop

stop

continue, run, quit

11-48

tbreak

11tbreak

tbreak t
tbreak

tbreak
tbreak
tbreak
/

break, bafter, xbreak, nanbreak, zcbreak

11-49

trace

11trace

trace gcb
trace s:b

s:b

s b

gcb

I/O

trace 1
I/O

disp, probe, untrace, slist

11-50

undisp

11undisp

undisp gcb
undisp s:b

s:b

s b

gcb

undisp

disp, slist

11-51

untrace

11untrace

untrace gcb
untrace s:b

s:b

s b

gcb

untrace

trace, slist

11-52

xbreak

11xbreak

xbreak

xbreak
xbreak
xbreak

break, bafter, zcbreak, tbreak, nanbreak

11-53

zcbreak

11zcbreak

zcbreak

zcbreak

zcbreak

break, bafter, xbreak, tbreak, nanbreak, zclist

11-54

zclist

11zclist

zclist

zclist
MATLAB

zcbreak

11-55

zclist

11-56

12
Performance Tools
Simulink Performance Tools

. . . . . . . . . . . .12-2

. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
Simulink Accelerator . . . . . . . . . . .
. . . . . . . . . . . .
Accelerator . . . . . . . . . . . .
. . . . . . . . . . .
Simulink Accelerator Simulink Debugger . . . .
Simulink Accelerator . .
. . . . . . . . . . . . . . . . . . . .
Simulink Accelerator Build . . .
Simulink Accelerator S-
Simulink Accelerator

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.12-3
12-3
12-4
12-5
12-6
12-7
12-8
12-9
12-10
12-10
12-11

Model Differencing Tool . . . . . . . . . . . . . . . . . . 12-13

. . . . . . . . . . . . . . . . . . . . . 12-15
. . . . . . . . . . . . . . . . . 12-15
. . . . . . . . . . .

. . .
. . .

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

12-17
12-17
12-19
12-20

Model Coverage Tool( ) .


Model Coverage Tool
Model Coverage Tool . . . . . . . .
. . . . . . . .
. . . . . . . . . . .
. . .
Model Coverage . . . . . . . . .

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

12-23
12-23
12-23
12-24
12-26
12-29
12-31

12 Performance Tools

Simulink Performance Tools


Simulink Performance Tools
Simulink Accelerator
Model Differencing Tool

Model Coverage Tool

Performance Tools

12-2

Simulink Accelerator

Simulink Accelerator
Simulink Accelerator Simulink MathWorks
Simulink Accelerator Simulink C
MathWorks Real-Time Workshop
C Simulink
Accelerator Real-Time Workshop Real-Time
Workshop Windows PC C
MathWorks lcc

Simulink Performance Tools

Simulink Accelerator Simulink Normal ( Accelerator


) C
Accelerator Simulink
C MATLAB MEX
Simulink
Simulink Accelerator Normal Simulink
Simulink Accelerator
Simulink

Simulink

Simulink 2 6

12-3

12 Performance Tools

Simulink Accelerator
Simulink Accelerator Simulation
Accelerator F14

12-1: Simulink Accelerator

Accelerator

Simulation Start
Accelerator C
Accelerator
modelname_accel_rtw ( f14_accel_rtw)

MEX-

12-4

Simulink Accelerator

mex
MATLAB mex -setup
C

Accelerator Real-Time
Workshop

Real-Time Workshop

Simulink Accelerator
MEX-
MATLAB MATLAB Simulink
MEX-
Simulink
Accelerator C MEX- (
)
Accelerator




Trigonometric Function
Sum
S- TLC
Simulink Accelerator

Gain

12-5

12 Performance Tools

Accelerator
Accelerator

Accelerator
Simulink Accelerator Simulink

Accelerator

Simulation Parameters Simulation Parameters Diagnostics Advanced


Accelerator

- Diagnostics Consistency checking Bounds checking


- Advanced Signal storage reuse
Stateflow Accelerator Stateflow Stateflow
Stateflow
Stateflow
S- Accelerator
Target Language Compiler
S-
Real-Time Workshop TLC
Simulink
(API) S-Function C

S- Target Language Compiler


Reference Guide Math Works Web
www.mathworks.com MATLAB CD

Simulink blocksets S- Accelerator


Simulink
Blockset
TLC M- C-MEX
S-Function
Workspace I/OTo WorkspaceTo File
Scope Accelerator

12-6

Simulink Accelerator

Accelerator Normal
(
) Accelerator

Simulink Accelerator MathWorks


Fixed Point Blockset DSP Blockset 2 Accelerator

SimulinkFixed Point Blockset DSP Blockset


Accelerator
Simulink DSP Blockset

12-1:
Simulink

DSP Blockset

Display

Biquadratic Filter

From File

Convolution

From Workspace

Direct-Form II Transpose Filter

Inport ( )

Dyadic Analysis Filter Bank/


Dyadic Synthesis Filter Bank

MATLAB Fcn

FIR Decimation/FIR Interpolation/


FIR Rate Conversion

Outport (
)

From Wave Device/From Wave File

Scope

Integer Delay/Variable Integer Delay

To File

Matrix Multiply/Matrix To Workspace

To Workspace

Triggered Signal To Workspace/


Triggered Signal From Workspace

12-7

12 Performance Tools

12-1: (Continued)
Simulink

DSP Blockset

Transport Delay

Time-Varying Direct-Form II Transpose Filter

Variable Transport Delay

To Wave File/To Wave Device

XY Graph

Wavelet Analysis/Wavelet Synthesis


Zero Pad

Accelerator Target Language Compiler


S- SS_OPTION_USE_TLC_WITH_ACCELERATOR
S-Function (M, Fortran, C)
12-11 Simulink Accelerator S-

Simulink Accelerator Simulink Debugger


Simulink Accelerator

Accelerator

Accelerator Simulink
Simulation Accelerator MATLAB
sldebug modelname


tbreak 10000
continue

emode (execution )
Accelerator Normal execution
Accelerator
Simulink 11 Simulink

12-8

Simulink Accelerator

Simulink Accelerator
set_param, sim, accelbuild 3 MATLAB
M-

MATLAB

set_param(gcs,simulationmode,mode)

set_param(modelname,simulationmode,mode)

gcs ("get current system") (


)
modelname
simulationmode normal accelerator

sim(gcs); % MATLAB

set_param(gcs,simulationcommand,start); % MATLAB

gcs modelname

Simulink Accelerator MEX-


accelbuild
Simulink Accelerator MEX-
accelbuild f14

accelbuild Accelerator MEX-


C
Accelerator

12-9

12 Performance Tools

MEX-

accelbuild MEX-

accelbuild f14 OPT_OPTS=-g

Simulink Accelerator Normal Simulink


tic,...,toc sim F14
(Normal
tic,[t,x,y]=sim(f14,1000);toc
elapsed_time =
14.1080

Accelerator
elapsed_time =
6.5880

233 MHz Pentium Windows PC

Accelerator MEX-
Normal

Simulink Accelerator Build


Simulink Accelerator
Accelerator MEX-
Real-Time Workshop
3
AccelMakeCommand
AccelSystemTargetFile
AccelTemplateMakeFile

12-10

Simulink Accelerator

3 Make
makefiles
Real-Time
Workshop Make
makefile Real-Time Workshop
Users Guide MathWorks Web
www.mathworks.com MATLAB CD

set_param(gcs, parameter, string)

set_param(modelname, 'parameter', 'string)

gcs ("get current system")


parameter 3 1 string

Simulink Accelerator S-
Target Language Compiler S-
Simulink Accelerator
Accelerator S- TLC

1 I/O
S-Function S- TLC
I/O
Accelerator
S- TLC

TLC S- MEX-

S-
S- mdlInitializeSizes
SS_OPTION_USE_TLC_WITH_ACCELERATOR S MEX- TLC

12-11

12 Performance Tools

Accelerator

static void mdlInitializeSizes(SimStruct *S)


{
/* Code deleted */
ssSetOptions(S, SS_OPTION_USE_TLC_WITH_ACCELERATOR);
}

12-12

Model Differencing Tool

Model Differencing Tool


Model Differencing Tool 2 Simulink

Simulink Performance Tools

2 1
Simulink Tool Model differences Model
Differencing Tool Select Second Model

12-13

12 Performance Tools

Select Second Model


Model Differences Tool 2
Model Differences Tool 2

Model Differences Tool 3

2
2
2

( )

12-14

Model Differencing Tool

Options
Show items with differences only 2
Include only non-graphical differences

View HTML Report 2


HTML

12-15

12 Performance Tools

12-16

Simulink

Simulink

Simulink Performance Tools

Sim()
ModelInitialize().
ModelExecute()
for t = tStart to tEnd
Output()
Update()
Integrate()
Compute states from derivs by repeatedly calling:
MinorOutput()
MinorDeriv()
Locate any zero crossings by repeatedly calling:
MinorOutput()
MinorZeroCrossings()
EndIntegrate
Set time t = tNew.
EndModelExecute
ModelTerminate
EndSim

12-17

12 Performance Tools

Simulink
0 1 Simulink

12-18

sim

ModelInitialize

ModelExecute

output
updateintegrate

Output

Update

Integrate

MinorOutput

MinorDeriv

MinorZeroCrossings

ModelTerminate

Nonvirtual Subsystem

output,
update, integrate

( 3-13 Atomic

Simulink Tools
Profiler
Simulink MATLAB help browser

12-19

12 Performance Tools

Simulink MATLAB

12-20

Total Recorded Time

Number of Block Methods

( Output())

Number of Internal Methods

( ModelExecute)

Number of Nonvirtual
Subsystem Methods

Clock Precision

Name

Time

Calls

Time/Call

Self Time

Location

MATLAB help browser

12-21

12 Performance Tools

( )
( )

12-22

Model Coverage Tool( )

Model Coverage Tool( )


Model Coverage Tool

model coverage( )

Model Coverage Tool

Model Coverage Tool Simulink Performance Tools

Model Coverage Tool


Model Coverage Tool

Switch
Multiport Switch
Triggered subsystem (Trigger )
Enabled subsystem (Enable )
Absolute Value
Saturation
Stateflow

Model Coverage Tool


Model Coverage Tool
1 1 ( 12-24

12-23

12 Performance Tools

2
3 Simulink
4

Simulink Model Coverage Tool


MATLAB
simcovdemo

Test Coverage Tool 2


MATLAB cvtest cvsim ( 12-33 cvsim
12-33 cvtest )
Coverage Tool Simulink
Tools Coverage Settings Simulink Coverage
Settings ( 12-29
) Enable Coverage Reporting
OK Simulation
Start Simulink

Simulink covdata
HTML

12-24

Model Coverage Tool( )

Simulink
Stateflow Model Converage Tool

12-25

12 Performance Tools

Model Converage Tool

Summary

Tests

12-26

Model Coverage Tool( )

Test throttle,
cvtest
Model Systems

Details ( )
Details

Details

12-27

12 Performance Tools

Simulink

MATLAB

backward( ) forward( )
forward
back

Stateflow

12-28

Model Coverage Tool( )

Coverage Settings

Enable converage Reporting( )


Simulinkh

Coverage Instrumentation Path( )


Simulink
Simulink

12-29

12 Performance Tools

Browse

Simulink System Selector

OK

Save to workspace( )
Simulink

Increment variable name with each simulation(


)

Generate HTML report(HTML )


HTML
MATLAB

Additional data to include in report( )

12-30

Model Coverage Tool( )

Model Coverage
cvhtml
cvdata HTML
cvhtml(file,data)

cvdata data HTML


file
cvhtml(file,data1,data2,...)

cvhtml(file,data,data2,...,detail)

0 3 detail
2

cvload

[TESTS, DATA] = CVLOAD(FILENAME)

FILENAME.CVT
cvtest TESTS
DATA cvdata
DATA TESTS

Simulink

12-31

12 Performance Tools

cvreport

cvreport(file,data)

cvdata

cvreport(file,data1,data2,...)

cvreport(file,data1,data2,...,detail)

0 3 detail
2

cvsave

cvsave(filename,model)

filename.cvt model

cvsave(filename, test1, test2, ...)


filename.cvt

cvsave(filename, data1, data2, ...)

filename.cvt

12-32

Model Coverage Tool( )

cvsim

( 12-24
)

data = cvsim(test)

cvtest
test cvdata
[data,t,x,y] = cvsim(test)

t x y
[data,t,x,y] = cvsim( test, timespan, options)
sim

[data1, data2, ...] = cvsim( test1, test2, ... )


cvdata
[data1,t,x,y] = cvsim(root, label, setupcmd)

cvtest

cvtest

test = cvtest(root, label, setupcmd)

root
label setupcmd
cvsim MATLAB
2 2 cvtest

12-33

12 Performance Tools

12-34

. . . . . . . . . . . . . . . . . . . . . . . . . A-2

. . . . . . . . . . . . . . . . . . . . . A-3

. . . . . . . . . . . . . . . . . . A-7
. . . . . . . . . . . . . . . . . A-10

. . . . . . . . . . . . . . . . . . . . A-26

set_param
10-27
set_param

A-2

B.
471

Simulation Parameters

58
Simulation Parameters

( )

( )

A-1:

AbsTol

{1e6}

AlgebraicLoopMsg

none | {warning} | error

ArrayBoundsChecking

'none' | 'warning' | 'error'

BooleanDataType

Boolean

on | {off}

BufferReuse

I/O

{on} | off

CloseFcn

ConfigurationManager

ConsistencyChecking

on | {off}

Created

Creator

Decimation

{1}

Description

ExternalInput

[t, u]

A-3

A-1: (Continued)

A-4

FinalStateName

{xFinal}

FixedStep

{auto}

InitialState

{xInitial}

InitialStep

{auto}

InvariantConstants

on | {off}

LimitDataPoints

on | {off}

LoadExternalInput

on | {off}

LoadInitialState

on | {off}

MaxDataPoints

{1000}

MaxOrder

ode15s

1 | 2 | 3 | 4 | {5}

MaxStep

{auto}

MinStepSizeMsg

{warning} | error

ModelVersionFormat

ModifiedBy

ModifiedDateFormat

Name

ObjectParameters

OutputOption

|
{ } |

OutputSaveName

{yout}

OutputTimes

OutputOption

{[]}

PaperOrientation

portrait | {landscape}

PaperPosition

[left, bottom, width, height]

A-1: (Continued)

PaperPositionMode

auto | {manual}

PaperSize

PaperUnits PaperType

[width height] (read only)

PaperType

{usletter} | uslegal | a0 | a1 | a2 | a3 | a4 | a5
| b0 | b1 | b2 | b3 | b4 | b5 | arch-A | arch-B |
arch-C | arch-D | arch-E | A | B | C | D | E |
tabloid

PaperUnits

normalized | {inches} | centimeters | points

PostLoadFcn

PreLoadFcn

Refine

{1}

RelTol

{1e3}

SampleTimeColors

Sample Time Colors

on | {off}

SaveFcn

SaveFinalState

on | {off}

SaveFormat

MATLAB

| |

SaveOutput

{on} | off

SaveState

on | {off}

SaveTime

{on} | off

ShowLineWidths

Show Line Widths

on | {off}

SimParamPage

Simulation Parameters
(
)

{Solver} | I/O |

Solver

{ode45} | ode23 | ode113 | ode15s | ode23s


| ode5 | ode4 | ode3 | ode2 | ode1 |
|

StartFcn

A-5

A-1: (Continued)

StartTime

{0.0}

StateSaveName

{xout}

StopFcn

StopTime

{10.0}

TimeSaveName

{tout}

UnconnectedInputMsg

none | {warning} | error

UnconnectedLineMsg

none | {warning} | error

UnconnectedOutputMsg

none | {warning} | error

Version

Simulink
( )

(release)

WideVectorLines

Wide Vector Lines

on | {off}

ZeroCross

( 314
)

{on} | off

mymodel

set_param(mymodel,StartTime,5,StopTime,100)

ode15s
set_param(mymodel,Solver,ode15s,MaxOrder,3)

SaveFcn
set_param(mymodel,SaveFcn,my_save_cb)

A-6

471
Simulink

A-2:

AttributesFormat
String

BackgroundColor

black | {white} | red | green | blue | cyan | magenta | yellow |


gray | lightBlue | orange | darkGreen

BlockDescription

BlockType

CloseFcn

MATLAB

CompiledPortWidths

CopyFcn

MATLAB

DeleteFcn

MATLAB

Description

DialogParameters

DropShadow

{off} | on

FontAngle

( ) {normal} | italic | oblique

FontName

{Helvetica}

FontSize

{10}

FontWeight

( ) light | {normal} | demi | bold

ForegroundColor

{black} | white | red | green | blue | cyan | magenta | yellow |


gray | lightBlue | orange | darkGreen

A-7

A-2: (Continued)

A-8

InitFcn

MATLAB

InputPorts

[h1,v1; h2,v2; ...]

LinkStatus

none |resolved | unresolved | implicit

LoadFcn

MATLAB

ModelCloseFcn

MATLAB

Name

NameChangeFcn

MATLAB

NamePlacement

{normal} | alternate

ObjectParameters

OpenFcn

MATLAB

Orientation

{right} | left | down | up

OutputPorts

[h1,v1; h2,v2; ...]

Parent

string

ParentCloseFcn

MATLAB

Position

[left top right bottom]

PostSaveFcn

MATLAB

PreSaveFcn

MATLAB

Selected

on | {off}

ShowName

{on} | off

A-2: (Continued)

StartFcn

MATLAB

StopFcn

MATLAB

Tag

Type

Simulink(
)

block

UndoDeleteFcn

MATLAB

UserData

MATLAB
(mdl
)

[]

mymodel Gain
( )
set_param(mymodel/Gain,Orientation,left)

OpenFcn mymodel Gain

set_param(mymodel/Gain,OpenFcn,my_open_cb)

mymodel Gain Position


75 25

set_param(mymodel/Gain,Position,[50 250 125 275])

A-9

Simulink
set_param
BlockType
BlockType

MaskType

A-26

( )( )
( )

A-3: Sources
(Block Type)/

Band-Limited White Noise (Continuous White Noise) ( )


Chirp Signal (chirp) (masked)
VectorParams1D

Interpret vector parameters as


1-D

off {on}

Clock (Clock) (no block-specific parameters)


Constant (Constant)
Value

Constant value

{1}

VectorParams1D

Interpret vector parameters as


1-D

off {on}

Digital Clock (DigitalClock)

A-10

A-3: Sources (Continued)


(Block Type)/

Sample time

(sample period) {1}


[period offset]

Interpret vector parameters as


1-D

off {on}

Filename

{untitled.mat}

Matrix table

{[T,U]}

Interpret vector parameters as


1-D

off {on}

Interpret vector parameters as


1-D

off {on}

Seed

Initial seed

{0}

VectorParams1D

Interpret vector parameters as


1-D

off {on}

SampleTime

Digital Pulse Generator


VectorParams1D

From File (FromFile)


FileName
From Workspace (FromWorkspace)
VariableName
Pulse Generator (Pulse Generator) (masked)
VectorParams1D

Ramp (Ramp) (masked)


VectorParams1D

Random Number (RandomNumber)

Repeating Sequence (Repeating table) (masked)


Signal Generator (SignalGenerator)
WaveForm

Wave form

{sine} | square | sawtooth | random

Amplitude

Amplitude

{1}

Frequency

Frequency

{1}

Units

Units

{Hertz} | rad/sec

A-11

A-3: Sources (Continued)


(Block Type)/

Interpret vector parameters as


1-D

off {on}

Amplitude

Amplitude

{1}

Frequency

Frequency

{1}

Phase

Phase

{0}

SampleTime

Sample time

( ) {1}
[period offset]

VectorParams1D

Interpret vector parameters as


1-D

off {on}

Time

Step time

{1}

Before

Initial value

{0}

After

Final value

{1}

VectorParams1D

Interpret vector parameters as


1-D

off {on}

VectorParams1D

Sine Wave (Sin)

Step (Step)

Uniform Random Number (Uniform RandomNumber)

A-12

Minimum

Minimum

{1}

Maximum

Maximum

{1}

Seed

Initial Seed

{0}

SampleTime

Sample Time

{0}

VectorParams1D

Interpret vector parameters as


1-D

off {on}

A-4: Sinks
(Block Type)/

Format

Format

{short} | long | short_e | long_e | bank

Decimation

Decimation

{1}

Floating

Floating display

{off} on

SampleTime

Sample time

( ) {1}
[period offset]

Location

Position of Scope window on


screen

{[left top right bottom]}

Open

(If Scope open when the


model is opened. Cannot set
from dialog box)

{off} | on

NumInputPorts

Number of Axes

> 0

TickLabels

Hide tick labels

{on} | off

ZoomMode

(Zoom button initially


pressed)

{on} | xonly | yonly

AxesTitles

Title (on right click axes)

{auto}

Grid

(for future use)

{on} | off

TimeRange

Time range

{auto}

YMin

Y min

{5}

YMax

Y max

{5}

SaveToWorkspace

Save data to workspace

{off} | on

SaveName

Variable name

{ScopeData}

DataFormat

Format

{ | }

Display (Display)

Scope (Scope)

A-13

A-4: Sinks (Continued)


(Block Type)/

LimitMaxRows

Limit rows to last

{on} | off

MaxRows

(no label)

{5000}

Decimation

(Value if Decimation
selected)

{1}

SampleInput

(Toggles with Decimation)

{off} | on

SampleTime

(SampleInput value)

( ) {0}
[period offset]

Stop Simulation (StopSimulation) (no block-specific parameters)


To File (ToFile)
Filename

Filename

{untitled.mat}

MatrixName

Variable name

{ans}

Decimation

Decimation

{1}

SampleTime

Sample time

( ) {1}
[period offset]

VariableName

Variable name

{simout}

Buffer

Maximum number of rows

{inf}

Decimation

Decimation

{1}

SampleTime

Sample time

( ) {1}
[period offset]

To Workspace (ToWorkspace)

XY Graph (XY scope.) (masked)

A-14

A-5: Discrete
(Block Type)/

Numerator

Numerator

{[1]}

Denominator

Denominator

{[1 2]}

SampleTime

Sample time

( ) {1}
[period offset]

{1}

{1}

{1}

{1}

X0

Initial conditions

{0}

SampleTime

Sample time

( ) {1}
[period offset]

Discrete Filter (DiscreteFilter)

Discrete State-Space (DiscreteStateSpace)

Discrete-Time Integrator (DiscreteIntegrator)


IntegratorMethod

Integrator method

{ForwardEuler} | BackwardEuler | Trapezoidal

ExternalReset

External reset

{none} | rising | falling | either

InitialConditionSource

Initial condition source

{internal} | external

InitialCondition

Initial condition

{0}

LimitOutput

Limit output

{off} | on

UpperSaturationLimit

Upper saturation limit

{inf}

LowerSaturationLimit

Lower saturation limit

{inf}

ShowSaturationPort

Show saturation port

{off} | on

ShowStatePort

Show state port

{off} | on

A-15

A-5: Discrete (Continued)


(Block Type)/

Sample time

( ) {1}
[period offset]

Numerator

Numerator

{[1]}

Denominator

Denominator

{[1 0.5]}

SampleTime

Sample time

( ) {1}
[period offset]

Zeros

Zeros

{[1]}

Poles

Poles

[0 0.5]

Gain

Gain

{1}

SampleTime

Sample time

( ) {1}
[period offset]

SampleTime

Discrete Transfer Fcn (DiscreteTransferFcn)

Discrete Zero-Pole (DiscreteZeroPole)

First-Order Hold (First Order Hold) (masked)


Unit Delay (UnitDelay)
X0

Initial condition

{0}

SampleTime

Sample time

( ) {1}
[period offset]

Sample time

( ) {1}
[period offset]

Zero-Order Hold (ZeroOrderHold)


SampleTime

A-16

A-6: Continuous
(Block Type)/

Derivative (Derivative) (no block-specific parameters)


Integrator (Integrator)
ExternalReset

External reset

{none} | rising | falling | either

InitialConditionSource

Initial condition source

{internal} | external

InitialCondition

Initial condition

{0}

LimitOutput

Limit output

{off} | on

UpperSaturationLimit

Upper saturation limit

{inf}

LowerSaturationLimit

Lower saturation limit

{inf}

ShowSaturationPort

Show saturation port

{off} | on

ShowStatePort

Show state port

{off} | on

AbsoluteTolerance

Absolute tolerance

{auto}

X0

Initial condition

{0}

InheritSampleTime

Inherit sample time

{off} | on

{1}

{1}

{1}

{1}

X0

Initial conditions

{0}

Numerator

{[1]}

Memory (Memory)

State-Space (StateSpace)

Transfer Fcn (TransferFcn)


Numerator

A-17

A-6: Continuous (Continued)


(Block Type)/

Denominator

{[1 1]}

DelayTime

Time delay

{1}

InitialInput

Initial input

{0}

BufferSize

Initial buffer size

{1024}

Denominator
Transport Delay (TransportDelay)

Variable Transport Delay (VariableTransportDelay)


MaximumDelay

Maximum delay

{10}

InitialInput

Initial input

{0}

MaximumPoints

Buffer size

{1024}

Zeros

Zeros

{[1]}

Poles

Poles

{[0 1]}

Gain

Gain

{[1]}

Zero-Pole (ZeroPole)

A-7: Math
(Block Type)/

Abs (Abs) (no block-specific parameters)


Algebraic Constraint (Algebraic Constraint) (masked)
Combinatorial Logic (CombinatorialLogic)
TruthTable

Truth table

{[0 0;0 1;0 1;1 0;


0 1;1 0;1 0;1 1]}

Complex to Magnitude-Angle

A-18

A-7: Math (Continued)


(Block Type)/

Gain

{1}

Operator

Operator

{AND} | OR | NAND | NOR | XOR | NOT

Inputs

Number of input ports

{2}

Function

{exp} | log | log10 | square | sqrt | pow | reciprocal |


hypot | rem | mod

Function

Function

{min} | max

Inputs

Number of input ports

{1}

Number of inputs

{2}

Operator

== | != | < | {<=} | >= | >

Operator

== | != | < | {<=} | >= | >

Function

{floor} | ceil | round | fix

Complex to Real-Imag
Dot Product (Dot Product) (masked)
Gain (Gain)
Gain
Logical Operator (Logic)

Magnitude-Angle to Complex
Math Function (Math)
Operator

Matrix Gain (Matrix Gain) (masked)


MinMax (MinMax)

Product (Product)
Inputs
Relational Operator (RelationalOperator)
Operator
Relational Operator (RelationalOperator)
Operator
Rounding Function (Rounding)
Operator

Sign (Signum) (no block-specific parameters)

A-19

A-7: Math (Continued)


(Block Type)/

List of signs

{++}

Function

{sin} | cos | tan | asin | acos | atan | atan2 | sinh |


cosh | tanh

Slider Gain (SliderGain) (masked)


Sum (Sum)
Inputs
Trigonometric Function (Trigonometry)
Operator

A-8: Functions and Tables


(Block Type)/

Expression

{sin(u(1)*exp(2.3*(u(2))))}

InputValues

Vector of input values

{[5:5]}

OutputValues

Vector of output values

{tanh([5:5])}

Fcn (Fcn)
Expr

Look-up Table (Lookup)

Look-Up Table (2-D) (Lookup Table (2-D)) (masked)


RowIndex

Row

ColumnIndex

Column

OutputValues

Table

2-D

MATLABFcn

MATLAB function

MATLAB {sin}

OutputWidth

Output width

{1}

MATLAB Fcn (MATLABFcn)

S-Function (S-Function)

A-20

A-8: Functions and Tables (Continued)


(Block Type)/

FunctionName

S-function name

{system}

Parameters

S-function parameters

A-9: Nonlinear
(Block Type)/

BacklashWidth

Deadband width

{1}

InitialOutput

Initial output

{0}

Backlash (Backlash)

Coulomb & Viscous Friction (Coulombic and Viscous Friction) (masked)


Dead Zone (DeadZone)
LowerValue

Start of dead zone

{0.5}

UpperValue

End of dead zone

{0.5}

Number of inputs

{3}

Quantization interval

{0.5}

RisingSlewLimit

Rising slew rate

{1.}

FallingSlewLimit

Falling slew rate

{1.}

OnSwitchValue

Switch on point

{eps}

OffSwitchValue

Switch off point

{eps}

Manual Switch (Manual Switch) (masked)


Multiport Switch (MultiPortSwitch)
Inputs
Quantizer (Quantizer)
QuantizationInterval
Rate Limiter (RateLimiter)

Relay (Relay)

A-21

A-9: Nonlinear (Continued)


(Block Type)/

OnOutputValue

Output when on

{1}

OffOutputValue

Output when off

{0}

UpperLimit

Upper limit

{0.5}

LowerLimit

Lower limit

{0.5}

FunctionName

S-function name

{system}

Parameters

S-function parameters

Saturation (Saturate)

S-Function (S-Function)

Sign (Signum) (no block-specific parameters)


Switch (Switch)
Threshold

Threshold

{0}

A-10: Signals & Systems


(Block Type)/

Bus Selector (BusSelector)

InputSignals

Configurable Subsystem (mask)


Choice

Block choice

LibraryName

Library name

Data store name

{A}

Data Store Memory (DataStoreMemory)


DataStoreName

A-22

A-10: Signals & Systems (Continued)


(Block Type)/

Initial value

{0}

DataStoreName

Data store name

{A}

SampleTime

Sample time

( ) {1}
[period offset]

DataStoreName

Data store name

{A}

SampleTime

Sample time

( ) {1}
[period offset]

Number of outputs

{3}

StatesWhenEnabling

States when enabling

{held} | reset

ShowOutputPort

Show output port

{off} | on

Goto tag

{A}

GotoTag

Tag

{A}

TagVisibility

Tag visibility

{local} | scoped | global

Goto tag

{A}

InitialValue
Data Store Read (DataStoreRead)

Data Store Write (DataStoreWrite)

Data Type Conversion


Demux (Demux)
Outputs
Enable (EnablePort)

From (From)
GotoTag
Goto (Goto)

Goto Tag Visibility (GotoTagVisibility)


GotoTag

Ground (Ground) (no block-specific parameters)


Hit Crossing (HitCross)

A-23

A-10: Signals & Systems (Continued)


(Block Type)/

HitCrossingOffset

Hit crossing offset

{0}

HitCrossingDirection

Hit crossing direction

rising | falling | {either}

ShowOutputPort

Show output port

{on} | off

Initial value

{1}

Port

Port number

{1}

PortWidth

Port width

{1}

SampleTime

Sample time

( ) {1}
[period offset]

Number of inputs

{3}

Port

Port number

{1}

OutputWhenDisabled

Output when disabled

{held} | reset

InitialOutput

Initial output

{0}

ProbeWidth

Probe width

{on} | off

ProbeSampleTime

Probe sample time

{on} | off

ProbeCompexSignal

Probe complex signal

{on} | off

IC (InitialCondition)
Value
In (Inport)

Merge
Model Info (CMBlock) (mask)
Mux (Mux)
Inputs
Out (Outport)

Probe (Probe)

Subsystem (SubSystem)

A-24

A-10: Signals & Systems (Continued)


(Block Type)/
ShowPortLabels

Show/Hide Port Labels


Format menu item

{on} | off

Terminator (Terminator) (no block-specific parameters)


Trigger (TriggerPort)
TriggerType

Trigger type

{rising} | falling | either | function-call

ShowOutputPort

Show output port

{off} | on

Width (Width) (no block-specific parameters)

A-25

Mask Editor

A-11:

Mask

onoff

{on} | off

MaskCallbackString

Mask parameter callbacks

MaskCallbacks

Mask parameter callbacks

MaskDescription

Block description

MaskDisplay

Drawing commands

MaskEditorHandle

Mask editor figure handle (for internal use)

handle

MaskEnableString

Mask parameter enable status

MaskEnables

Mask parameter enable status

, on off

MaskHelp

Block help

MaskIconFrame

Icon frame ( on, off)

{on} | off

MaskIconOpaque

Icon transparency ( on
off)

{on} | off

MaskIconRotate

Icon rotation ( on off)

on | {off}

MaskIconUnits

Drawing coordinates

Pixel | {Autoscale} | Normalized

MaskInitialization

Initialization commands

MATLAB

MaskPrompts

Prompt ( )

MaskPromptString

Prompt ( )

Indicates that the block can modify itself.

on | {off}

MaskNames

MaskPropertyNameString
MaskSelfModifiable

A-26

A-11:

MaskStyles

Control type ( )

{Edit} | Checkbox | Popup

MaskStyleString

Control type ( )

{Edit} | Checkbox | Popup

MaskTunableValues

Tunable parameter attributes

MaskTunableValue

Tunable parameter attributes

MaskType

Mask type

MaskValues

Block parameter values ( )

MaskValueString

Block parameter values ( )

MaskVariables

Variable ( )

MaskVisibilities

Specifies visibility of parameters

String

Mask Editor

Prompt
Variable
Control type


Assignment

Prompt
(|)
MaskPromptString
"Slope:|Intercept:"

Variable
MaskVariables

A-27

Assignment
@ Evaluate & Literal
"a=@1;b=&2;"
a MATLAB
2 b

Control type
MaskStyleString
Popup strings popup

"edit,checkbox,popup(red|blue|green)"


MaskValueString

MaskPromptString "Slope:|Intercept:"
MaskValueString "2|5"

A-28

. . . . . . . . . . . . . . . . . . . . B-2

Model . . . . .
BlockDefaults . .
AnnotationDefaults
System . . . . .

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

B-3
B-3
B-3
B-3

ASCII

Model {
<Model Parameter Name> <Model Parameter Value>
...
BlockDefaults {
<Block Parameter Name> <Block Parameter Value>
...
}
AnnotationDefaults {
<Annotation Parameter Name> <Annotation Parameter Value>
...
}
System {
<System Parameter Name> <System Parameter Value>
...
Block {
<Block Parameter Name> <Block Parameter Value>
...
}
Line {
<Line Parameter Name> <Line Parameter Value>
...
Branch {
<Branch Parameter Name> <Branch Parameter Value>
...
}
}
Annotation {
<Annotation Parameter Name> <Annotation Parameter Value>
...
}
}
}

B-2

Model
BlockDefaults

AnnotationDefaults

System (
) System

Model
Model

Simulink

BlockDefaults
BlockDefaults

Block

AnnotationDefaults
AnnotationDefaults BlockDefaults

set_param

System
System
System

B-3

Block, Line, Annotation


Line Branch

B-4

You might also like