Anda di halaman 1dari 30

. .

,
210700

() ()

-
-
2012

681.3.06
32.973.26-018.2
60

60

. .
. Simulink. .: , 2012. 432 .: . ( )
ISBN 978-5-9775-0686-1
Simulink- () .
Simulink. Simulink- , . Simulink- ,
- - , , , .
, -
:
. . , - . , - ;
. . , . . , - .

681.3.06
32.973.26-018.2
:

.
.

14.03.2012.
701001/16. . . . . 34,83.
1200 .
"-", 190005, -, ., 29.

" ""
199034, -, 9 , 12.

ISBN 978-5-9775-0686-1

. ., 2012
, "-", 2012


................................................................................................................... 11
I. Simulink .................................................................................. 13
1. Simulink MATLAB ........................................................... 15
1.1. MATLAB. Simulink ............................... 15
1.2. ............................................................................................ 16
1.3. Simulink ................................................................................... 17
1.4. Simulink ................................................................................................ 19
1.5. MATLAB .................................................................................... 23
1.5.1. help ...................................................................................................... 24
1.5.2. Help MATLAB ...................................................................... 24
1.5.3. Help Simulink Library Browser .......................................... 26
2. S- ................................................. 28
2.1. S- ....................................................... 28
2.2. S- ....................................................... 31
2.3. S- ........................................................................ 35
2.3.1. S- .............................................. 35
2.3.2. S- .............................................. 38
2.4. S- ........................................................................................... 41
3. ........................................................ 43
3.1. S- ................................................................................. 43
3.2. S-
Workspace ........................................................................................................... 50
3.3. ................................................................ 54
3.4. , .......................................... 56
3.5. ...................................................... 56
4. .......................................................................................................... 58
4.1. S- ................................................................................................... 58
4.2. .................................................................................................... 59
4.2.1. Band-Limited White Noise ........................................................................ 60

4.2.2. Chirp Signal ............................................................................................... 62


4.2.3. Clock .......................................................................................................... 63
4.2.4. Constant ..................................................................................................... 64
4.2.5. Counter Free-Running................................................................................ 68
4.2.6. Counter Limited ......................................................................................... 69
4.2.7. Digital Clock .............................................................................................. 70
4.2.8. From File .................................................................................................... 70
4.2.9. From Workspace ........................................................................................ 72
4.2.10. Ground ..................................................................................................... 76
4.2.11. In .............................................................................................................. 76
4.2.12. Pulse Generator ........................................................................................ 78
4.2.13. Ramp ........................................................................................................ 79
4.2.14. Random Number ...................................................................................... 80
4.2.15. Repeating Sequence ................................................................................. 80
4.2.16. Repeating Sequence Interpolated ............................................................. 81
4.2.17. Repeating Sequence Stair......................................................................... 82
4.2.18. Signal Generator ...................................................................................... 83
4.2.19. Sine Wave ................................................................................................ 83
4.2.20. Step........................................................................................................... 85
4.2.21. Uniform Random Number ....................................................................... 86
4.3. .................................................................... 86
5. ......................................................................... 88
5.1. S- ....................................................................... 88
5.2. .................................................................................................... 89
5.2.1. Display ....................................................................................................... 89
5.2.2. Out .............................................................................................................. 90
5.2.3. Scope .......................................................................................................... 91
5.2.4. Stop Simulation .......................................................................................... 93
5.2.5. Floating Scope............................................................................................ 94
5.2.6. Terminator .................................................................................................. 94
5.2.7. To File ........................................................................................................ 94
5.2.8. To Workspace ............................................................................................ 95
5.2.9. XY Graph ................................................................................................... 98
6. .............................................................. 99
6.1. Simulink .................................................................. 99
6.1.1. ............................................................................... 99
6.1.1.1. Add ................................................................................................................. 100
6.1.1.2. Bias ................................................................................................................. 103
6.1.1.3. Divide ............................................................................................................. 103
6.1.1.4. Dot Product ..................................................................................................... 105
6.1.1.5. Gain ................................................................................................................ 105

6.1.1.6. Product............................................................................................................ 106


6.1.1.7. Product of Elements ........................................................................................ 108
6.1.1.8. Slider Gain ...................................................................................................... 108
6.1.1.9. Subtract ........................................................................................................... 108
6.1.1.10. Sum ............................................................................................................... 108
6.1.1.11. Sum of Elements ........................................................................................... 108
6.1.1.12. Unary Minus ................................................................................................. 108

6.1.2. ..................................................... 109


6.1.2.1. Abs .................................................................................................................. 109
6.1.2.2. Math Function................................................................................................. 110
6.1.2.3. Sign ................................................................................................................. 111
6.1.2.4. Trigonometric Function .................................................................................. 111

6.1.3. ............................................................. 111


6.1.3.1. Complex to Magnitude-Angle......................................................................... 112
6.1.3.2. Complex to Real-Imag .................................................................................... 112
6.1.3.3. Magnitude-Angle to Complex......................................................................... 113
6.1.3.4. Real-Imag to Complex .................................................................................... 113

6.1.4. Rounding Function........................................ 114


6.1.5. .............................................................. 115
6.1.5.1. Matrix Concatenate ......................................................................................... 115
6.1.5.2. MinMax .......................................................................................................... 116
6.1.5.3. Reshape........................................................................................................... 116
6.1.5.4. Vector Concatenate ......................................................................................... 117

6.1.6. ............................. 117


6.1.6.1. Algebraic Constraint ....................................................................................... 118
6.1.6.2. Polynomial ...................................................................................................... 118

6.1.7. .............................................. 119


6.1.7.1. Compare To Constant ..................................................................................... 119
6.1.7.2. Compare To Zero............................................................................................ 120
6.1.7.3. Relational Operator......................................................................................... 120
6.1.7.4. Logic Operator ................................................................................................ 121

6.1.8. ....................................................................................... 122


6.1.8.1. Bit Clear.......................................................................................................... 122
6.1.8.2. Bit Set ............................................................................................................. 123
6.1.8.3. Bitwise Operator ............................................................................................. 123
6.1.8.4. Shift Arithmetic .............................................................................................. 124

6.1.9. MATLAB .......................................................................................... 124


6.1.9.1. Fcn .................................................................................................................. 125
6.1.9.2. MATLAB Fcn ................................................................................................ 126
6.1.9.3. Embedded MATLAB Function ...................................................................... 127

6.1.10. ............................................................ 128


6.2. Signal Processing Blockset.................................... 128
6.2.1. ............................... 128
6.2.1.1. Complex Exponential ..................................................................................... 129
6.2.1.2. Cumulative Product ........................................................................................ 129
6.2.1.3. Cumulative Sum.............................................................................................. 131
6.2.1.4. dB Conversion ................................................................................................ 131

6.2.1.5. Difference ....................................................................................................... 132


6.2.1.6. Normalization ................................................................................................. 133

6.2.2. ............................................................................................ 135


6.2.2.1. Create Diagonal Matrix .................................................................................. 135
6.2.2.2. Extract Diagonal ............................................................................................. 136
6.2.2.3. Extract Triangular Matrix ............................................................................... 136
6.2.2.4. Identity Matrix ................................................................................................ 136
6.2.2.5. Toeplitz ........................................................................................................... 137

6.2.3. .................................................................................. 138


6.2.3.1. Matrix Concatenate ......................................................................................... 138
6.2.3.2. Overwrite Values ............................................................................................ 138
6.2.3.3. Permute Matrix ............................................................................................... 140
6.2.3.4. Submatrix........................................................................................................ 141

6.2.4. .................................. 141


6.2.4.1. Matrix Multiply .............................................................................................. 142
6.2.4.2. Matrix Product ................................................................................................ 142
6.2.4.3. Matrix Square ................................................................................................. 142
6.2.4.4. Matrix Sum ..................................................................................................... 143
6.2.4.5. ........................................ 143

6.2.5. ....................................................................................... 144


6.2.5.1. LU Inverse ...................................................................................................... 144
6.2.5.2. LDL Inverse .................................................................................................... 145
6.2.5.3. Cholesky Inverse............................................................................................. 146

6.2.6. ....................................................................................... 146


6.2.6.1. LU Factorization ............................................................................................. 147
6.2.6.2. QR Factorization............................................................................................. 148
6.2.6.3. Cholesky Factorization ................................................................................... 148

6.2.7. ............................... 149


6.2.7.1. LU Solver ....................................................................................................... 150
6.2.7.2. QR Solver ....................................................................................................... 150
6.2.7.3. Cholesky Solver .............................................................................................. 151

6.2.8. .................. 151


6.2.8.1. Autocorrelation ............................................................................................... 152
6.2.8.2. Correlation ...................................................................................................... 153
6.2.8.3. Maximum........................................................................................................ 154
6.2.8.4. Mean ............................................................................................................... 156
6.2.8.5. Minimum ........................................................................................................ 157
6.2.8.6. RMS ................................................................................................................ 157
6.2.8.7. Sort ................................................................................................................. 158
6.2.8.8. Standard Deviation ......................................................................................... 159
6.2.8.9. Variance .......................................................................................................... 160

7. ............................................................. 160
7.1. S- ........................................... 160
7.1.1. Mus........................................................................................................... 161
7.1.2. Demux ...................................................................................................... 162

7.1.3. Bus Creator .............................................................................................. 165


7.1.4. Bus Selector ............................................................................................. 166
7.1.5. Goto .......................................................................................................... 167
7.1.6. From ......................................................................................................... 169
7.1.7. Manual Switch ......................................................................................... 169
7.1.8. Switch....................................................................................................... 169
7.1.9. Selector..................................................................................................... 170
7.1.10. Merge ..................................................................................................... 173
7.2. S- ............................................ 176
7.2.1. Bus to Vector ........................................................................................... 176
7.2.2. Data Type Conversion ............................................................................. 177
7.2.3. Data Type Conversion Inherited .............................................................. 180
7.2.4. Data Type Duplicate ................................................................................ 181
7.2.5. IC .............................................................................................................. 181
7.2.6. Probe ........................................................................................................ 182
7.2.7. Rate Transition ......................................................................................... 183
7.2.8. Width ........................................................................................................ 185
7.3. S- .............................................................. 186
7.3.1. Integer Delay ............................................................................................ 186
7.3.2. Memory .................................................................................................... 187
7.3.3. Unit Delay ................................................................................................ 188
8. .................................................................................................. 189
8.1. ..................................................................................... 189
8.2. ................................................................................. 190
8.2.1. Create Subsystem .............................................................................. 190
8.2.2. Subsystem ................................................................................................ 191
8.2.3. ......................................................... 192
8.2.4. S- ............................................... 194
8.3. .................................................................... 195
8.3.1. Enabled Subsystem .................................................................................. 195
8.3.2. Triggered Subsystem................................................................................ 199
8.3.3. Enabled and Triggered Subsystem ........................................................... 203
8.4. , ........ 203
8.4.1. If Action Subsystem ................................................................................. 203
8.4.2. Switch Case Action Subsystem................................................................ 208
8.4.3. For Iterator Subsystem ............................................................................. 211
8.4.4. While Iterator Subsystem ......................................................................... 215
8.5. ................................................................................ 220
9. ........................................................................... 233
9.1. ...................................................................... 233
9.2. .......................................................................................... 235

10. S- ..................................................................... 240


10.1. .................................................................. 240
10.2. Debuggers GUI .......................................................... 241
II.
Simulink ......................................................................................................................... 249
11. ................................................................................ 251
11.1. : Simulink ........................................ 251
11.1.1. .......................................................... 252
11.1.2. ....................................................... 254
11.1.3. ........................................................... 255
11.1.4. ......................................................... 257
11.1.5. ............................................ 260
11.1.6. ......................................... 261
11.2. : Signal Processing Blockset ............ 262
11.2.1. S- ....................................... 262
11.2.1.1. Display .......................................................................................................... 262
11.2.1.2. Matrix Viewer ............................................................................................... 263
11.2.1.3. Signal To Workspace.................................................................................... 264
11.2.1.4. Triggered To Workspace .............................................................................. 265
11.2.1.5. Time Scope ................................................................................................... 267
11.2.1.6. Vector Scope ................................................................................................ 267
11.2.1.7. Waterfall ....................................................................................................... 272

11.2.2. S- ................................................................... 277


11.2.2.1. Chirp ............................................................................................................. 278
11.2.2.2. Constant ........................................................................................................ 279
11.2.2.3. Constant Diagonal Matrix ............................................................................. 279
11.2.2.4. Discrete Impulse ........................................................................................... 280
11.2.2.5. Identity Matrix .............................................................................................. 281
11.2.2.6. Random Sources ........................................................................................... 281
11.2.2.7. Signal From Workspace................................................................................ 282
11.2.2.8. Sine Wave ..................................................................................................... 283

11.2.3. .......................................................... 286


11.2.3.1. .................................................................. 286
11.2.3.2. ................................................................ 287
11.2.3.3. ................................................... 288
11.2.3.4. ................................................ 289

11.3. ................................................ 290


11.3.1. Buffer ..................................................................................................... 291
11.3.2. Unbuffer ................................................................................................. 293
11.3.3. Flip ......................................................................................................... 294
11.3.4. Convert 1-D to 2-D ................................................................................ 295
11.3.5. Convert 2-D to 1-D ................................................................................ 295

11.3.6. N-Sample Enable ................................................................................... 295


11.3.7. N-Sample Switch ................................................................................... 296
11.3.8. Data Type Conversion ........................................................................... 297
11.3.9. Owerwrite Values .................................................................................. 297
11.3.10. Selector................................................................................................. 297
11.3.11. Submatrix ............................................................................................. 298
11.4. ................................................................. 298
11.4.1. Constant Ramp ....................................................................................... 298
11.4.2. Convolution ............................................................................................ 299
11.4.3. Downsample ........................................................................................... 300
11.4.4. Pad .......................................................................................................... 301
11.4.5. Peak Finder ............................................................................................ 303
11.4.6. Repeat..................................................................................................... 305
11.4.7. Upsample................................................................................................ 306
11.4.8. Window Function ................................................................................... 306
11.4.9. Zero Crossing ......................................................................................... 309
11.5. ................................................. 310
12. ............................................................. 312
12.1. S- ......................................................... 312
12.2. S- ...................................................................................... 315
12.2.1. Discrete Filter......................................................................................... 316
12.2.2. Discrete FIR Filter ................................................................................. 317
12.2.3. Discrete State-Space .............................................................................. 318
12.2.4. Discrete Zero-Pole ................................................................................. 320
12.3. S- ............................................................... 322
13. ............................................................ 324
13.1. ................................................................ 324
13.2. - ..................................................................................... 325
13.3. - .............. 326
13.4. - ..................................................................................... 329
13.5. - .............. 330
13.6. ......................................................................... 330
13.7. S- ............ 333
13.8. S- ................................................................. 334
13.8.1. S- Digital Filter Design.......................................... 334
13.8.2. S- Filter Design Toolbox ........ 337
13.8.2.1. Lowpass Filter .............................................................................................. 337

13.9. S- ................................................................. 340


13.10. S- .................................................................................... 341
13.11. S- ......................................................... 351

10

14. ............ 353


14.1. S- ........................................................ 353
14.2. S- Filter Realization Wizard ..... 353
14.2.1. Workspace ....................................... 354
14.2.2.
-........................................................................................ 356
14.2.3. S- .............................................................. 360
14.2.4. .......................................................... 363
14.2.4.1. Coefficients ........................................ 364
14.2.4.2. Input/Output ....................................... 366
14.2.4.3. Filter Internals .................................... 369

14.2.5. S- ....................................................................... 373


14.3. S- Digital Filter .................................. 374
14.4. Digital Filter ............................................................................ 375
14.5. S-
MATLAB ................................................................................................... 379
14.6. S- ............................................................................. 380
14.7. S- ................................................. 380
15. .................................................................... 384
15.1. ............................................................................ 384
15.2. S- .................................................................. 386
15.2.1. FFT ......................................................................................................... 387
15.2.2. IFFT........................................................................................................ 389
15.2.3. Simulink ................................................. 389
15.3. S- ......... 390
16. ........................................................... 398
16.1. ....................... 399
16.2. ............................ 402
16.3. .............. 404
16.4.
MATLAB ..................................................................................................................... 405
16.5. S- ................................................................... 408
16.5.1. FIR Interpolation .................................................................................... 409
16.5.2. FIR Decimation ...................................................................................... 411
16.5.3. FIR Rate Conversion .............................................................................. 411
16.6. .................................. 412
.................................................................................................... 417
.................................................................................................... 419
................................................................. 419
....................................................................... 419
.............................................................................................. 421


().
(soft) (hard-)
(),
(), (System on Chip SoC) . .

.

.
,

. , soft- hard-.
" " (210700)
"" (210400) "
".
, .

( )
MATLAB,
. MATLAB , .
: "" ; ;
; ; (Toolbox), ,
(GUI) Simulink

.

12

" .
MATLAB"
MATLAB GUI.
Simulink, , MATLAB.
- , Simulink, ,
, .
Simulink . ,
.
. , Simulink ,
Simulink. , ,
, , Simulink. Simulink, .
Simulink,
.
- , , , , .
16 ,
:
1. Simulink.
2. Simulink.

, , "-" :
mail@bhv.ru.

Simulink

Simulink MATLAB
MATLAB ( MATLAB) , . The MathWorks, Inc., 80- . MATLAB www.mathworks.com, www.softline.ru,
www.matlab.ru www.exponenta.ru.
MATLAB R2009b
R2010a.
MATLAB :
MATLAB, Simulink, Toolbox Blockset.
MATLAB MATLAB.
Simulink () MATLAB, , ,
, Simulink. "simulink" "simulation" () "link" ().
Toolbox ( ) Blockset ( ) MATLAB Simulink , , .

1.1. MATLAB.
Simulink
/ MATLAB :
1. .
,
MATLAB,
MATLAB.
, . [22].

16

I. Simulink

2. GUI (Graphical User Interface -

).
GUI GUI.
GUI MATLAB,
MATLAB , ,
MATLAB.
GUI MATLAB,
, .
GUI [22].
3. Simulink.
Simulink .
Simulink MATLAB, MATLAB
, .
Simulink (Dynamic Systems).
Simulink , Simulink "".
, , "" "" , :
;
, .
.
Simulink .

1.2.
:

Times New Roman :

, Simulink Library Browser;


, New
File;

1. Simulink MATLAB

17

, , , , , . . , Sampling mode Source Block


Parameters: Constant;
, Sources,
Sources;
, Decimation Clock;
Courier New :
MATLAB, h=a+sin(b);
MATLAB , work;
Courier New MATLAB

, simulink;

" Simulink ,
".

MATLAB ,
, , , , ,
. . .

1.3. Simulink
Simulink MATLAB.
MATLAB
MATLAB ,
Product and Folder Selection ( )
Select Products to install ( ).
MATLAB Simulink.
.
,
.
, ,
MATLAB Simulink,
MATLAB (Toolbox) Simulink (Blockset), . 1.1. ,
Simulink, .
1.1. MATLAB

Communications Blockset

Communications Toolbox

Control System Toolbox

Curve Fitting Toolbox

18

I. Simulink
. 1.1

Filter Design Toolbox

Fixed Point Toolbox

Gauges Blockset

Neural Network Toolbox

Optimization Toolbox

Real-Time Windows Target

Windows

Real-Time Workshop

Signal Processing Blockset

Signal Processing Toolbox

Simulink Control Design

Simulink Fixed Point

Spline Toolbox

Statistics Toolbox

Symbolic Math Toolbox

System Identification Toolbox

Wavelet Toolbox

MATLAB
MATLAB. MATLAB
.

MATLAB, (. 1.1),
.
MATLAB :
Command Window ( )
MATLAB ;
Current Folder ( ) ,

Current Folder
MATLAB.
work, ,
;

Workspace ( )

, Workspace
MATLAB;

Command History ( )

MATLAB,
.

1. Simulink MATLAB

19

. 1.1. MATLAB


Desktop (). . 1.1
, Desktop Layout | Default ( |
).
MATLAB Windows
. Debug ()
[22].
MATLAB
:
ver

Simulink Simulink
MATLAB.
Simulink :
1. Simulink MATLAB.
2. Command Window:
simulink

1.4. Simulink
Simulink Simulink simulink
Simulink Library Browser ( Simulink)
(. 1.2).

20

I. Simulink

Simulink
Sources

. 1.2. Simulink Library Browser

:
Libraries Simulink (Simulink Library);
Simulink ,
.
Simulink :
,
(Block Library).
( ),
Simulink, Simulink;

1. Simulink MATLAB

21

( ), (Blocks).
;
, (Block);
: Library (),

, Libraries; Search Results ( ); Most Frequently Used Blocks


( ).
Library
, Libraries.
, -.
,
.
,

.
.

Search Results ,
;
:

File () Simulink , . 9;
Edit () Simulink , , Simulink;
View () Simulink Library Browser
.
Layout | List ( | )
, Layout | Grid
( | )
(. 1.3, . 1.2);
Help () Simulink MATLAB;
,

Block Description ( )

, ;
View Show Block Descriptions ( );

Enter search term ( ), Search for

subsystems and block by name ( )

22

I. Simulink

Search options ( ) (. . 1.2)


.

. 1.3. Simulink

(
) Search options ( ).
( ): Regular expression
( ); Match case ( ); Match whole word (
). Search for subsystems and block by name.
Search Results,
Found: '' (: ''),
,
(
) , .
. 1.4 "Constant"
Match whole word. ,
, .

1. Simulink MATLAB

23

. 1.4. "Constant" Match whole word

Simulink
MATLAB Simulink HTML
Simulink User Guide Simulink Graphical User Interface Library Browser.
Help | Library
Browser Help Simulink Library Browser (. . 1.5.3).

1.5. MATLAB
Simulink MATLAB,
:
, :
MATLAB, , . , ;

24

I. Simulink

HTML (Hyper Text Markup Language


)
MATLAB CD-.
, MATLAB, , , .
,
. ,
Command Window;
PDF (Portable Document Format
)
MATLAB. MATLAB, 7.0, CD-
, www.mathworks.com.
PDF Acrobat Reader.

" ", ,
- ,
.
, . ,
, MATLAB

;
.

MATLAB
, Simulink,
MATLAB Simulink
.

1.5.1. help
help .
Simulink :
>> help simulink

, :
>> help load_system

1.5.2. Help MATLAB


Help MATLAB
HTML MATLAB.
. ,
.

1. Simulink MATLAB

25

, ,
.
Help | Product Help Help
HTML, (. 1.5):
:
Contents () , MATLAB, HTML-, ,
;
Search Results ( )
(), ,
<Enter>. , () MATLAB, HTML-
(. 1.6);
HTML- ,

,
, .

. 1.5. Help MATLAB HTML


Contents

26

I. Simulink

. 1.6. Help MATLAB HTML


Search Results "Source"

1.5.3. Help
Simulink Library Browser
Help Simulink Library Browser (. . 1.2)
c MATLAB HTML
Simulink, ,
:
Help for the Selected Block ( ).

MATLAB HTML, Help HTML , Simulink
Library Browser (. 1.7);
Library Browser Help ( Simulink).

HTML-
Simulink (Library Browser);
Simulink Help ( Simulink).


MATLAB HTML Simulink (. 1.8).

1. Simulink MATLAB

27

. 1.7. Help MATLAB HTML, Help | Help for


the Selected Block Simulink Library Browser, Inport

. 1.8. Help MATLAB HTML, Help | Simulink


Help Simulink Library Browser


S-
, Simulink,
S- Simulink-.
,
" " .
MATLAB Simulink " "
(Modeling a System) S- (. .
Simulink),
"
" (Modeling a Dynamic System).
,
Simulink :
1. S- .
2. .
S- ,
. 3.

2.1. S-

(. . 1.1)
.
[23], ,
() ().
/,
,
(. 2.1, ):
(2.1)
Y F (X ) ,
, X Y (
), ;

2. S-

29

F , (
, . .).

. 2.1. () ()

(2.1) :
1. .
. [23]:
, .
, . - ;
, .
, . ( );
, .
, . .
2. F.

F , , .
F
() , (2.1)

30

I. Simulink

( ) .
F
()
, (2.1)
( )
.

F :
;
.
F
[23], (2.1)
.
, ,
, F
, .
S- (2.1).
S-
(2.1), F
, (2.1)
:
.

(. 2.1, ):
X;
, 1;
Y.

S-
:
S- X;
S- ;
S- Y.

, . 12.1.

Anda mungkin juga menyukai