Você está na página 1de 44

Simulink

Simulink

7.1 Simulink
7.1

(1) MATLAB simulink

Simulink (Simulink Library Browser) 7.1

7.1 Simulink

(2)

FileNewModeluntitled

(3) Source+( Source) Simulink Source

(4) Sine Wave() untitledSine Wave untitled


Sine Waveadd to 'untitled'Sine Wave untitled 7.2

7.2 Simulink

(5) SinksScope()untitled
(6) untitledSine WaveScope
7.3
(7) untitled

SimulinkStart Scope

7.4
(8)
Ex0701.mdl

7.3 Simulink
7.4

7.2 Simulink

7.2.1 Simulink
1.

MATLAB FileNewModel
7.1 Simulink FileNewModel
7.3 Simulink FileNewModel

2.

MATLAB Ex0701
MATLAB FileOpen

7.1 Simulink FileOpen


7.3 Simulink FileOpen

7.2.2 Simulink

.mdl

7.5

1.
2.
7.6

exe

7.6

3.
Simulink 7.1
7.1


File

Edit

View

Simulation

Format

Tools

NewModel
Model properties
Preferences
Print
Close
Exit MATLAB
Create subsystem
Mask subsystem
Look under mask
Update diagram
Go to parent
Model browser options
Block data tips options
Library browser
Fit system to view
Normal
StartStop
PauseContinue
Simulation Parameters
Normal
Accelerator
Text alignment
Filp name
ShowHide name
Filp block
Rotate Block
Library link display
ShowHide drop shadow
Sample time colors
Wide nonscalar lines
Signal dimensions
Port data types
Storage class
Data explorer
Simulink debugger
Data class designer
Linear Analysis

SIMULINK

Simulink
MATLAB

(100%)

Simulink
Simulink

Simulink

7.3

7.3.1
1.


Shift
7.7

7.7

EditSelect all
2.
(1) ()

CopyPaste
CopyPaste
(2) ( 7.8 )

Ctrl
CopyPaste

7.8

3.


Shift

4.
Delete EditClearCutCut
5.

6.
180
FormatFlip Block 180 7.9 180
90
FormatRotateBlock 90 7.9

7.9

7.


FormatFont

FormatHide /Show name

FormatFlip name

7.3.2
1.

2.
(1)
Ctrl
7.10
(2)

7.10

Shift 7.11

7.11

3. (label)


Ctrl
4.

7.3.3
(1)

(2)

7.4 Simulink

7.4.1
Simulink 9
1.

(Sources)

7.2
7.2

Constant

Step

Ramp

Sine Wave

Signal Generator

From File

From Workspace

Clock

In

2. (Sinks)
7.3
7.3

Scope

Display

XY Graph

X-Y

To File

To Workspace

Stop Simulation

Out

3. (Continuous)
7.4
7.4

Integrator

Derivative
State-Space

Transfer Fcn
Zero-Pole

Transport Delay

4. (Discrete)
7.5

7.5

Discrete Transfer Fcn

Discrete Zero-Pole

Discrete State-Space

Discrete Filter

Zero-Order Hold

First-Order Hold

Unit Delay

7.4.2
1.
(1) (Sine Wave)
7.13

7.13

Sine type Time-based

Sample-based Amplitude Bias

Frequency Phrase Sample

time
(2) (Step)

7.14

Step time

initial value Final value Sample time

(3) (From workspace)

7.2 t y

t=0:0.1:10;
7.13

7.14

y=sin(t);
t=t';

y=y';
From Workspace 7.15(a)Data[t,y]OK 7.15(b)

7.15 (a)

(b)

DataFrom WorkspaceData+1

t=0:0.1:2*pi;
y=sin(t);
y1=[t;y];
save Ex0702 y1

%Ex0702.mat

(4) (From file)


mat

7.2.mat
t=0:0.1:2*pi;
y=sin(t);

7.16 From File

y1=[t;y];

save Ex0702 y1

%Ex0702.mat

From File 7.16 File nameEx0702.matOK

(5) (Transfer function)


7.17

Denominator[1 1.414 1]
7.18
7.18

7.17

7.19

(6) (Scope)

X-Y

7.19

2.
7.22

7.22

(1) (Description)

(2) (Priority)

(3) (Tag)

(4) (Open function)


MATLAB
(5) (Attributes format string)

7.23

7.5
Simulink

7.5.1
SimulationSimulation parameters 7.24
1. Solver

7.24 Solver

(1)
(Start time)
(Stop time)
(2)
Solve options

(3)
Type
(4)
(Output options)
2. Workspace I/O()
7.25 Simulink

7.25 Workspace I/O

(1) (Load from workspace)


(2) (Save to workspace)

Time

Time ()( tout)


States
States ( xout)
Output
Out Output ( yout)
Final state
Final state ( xFinal)

(3) (Save options)


Save options Save to workspace

7.5.2
7.3

1
2

s + 0.6s

(1) SourcesStepContinuousTransfer FcnMath OperationsSumSinksScope


(2)
(3) Sum 7.26 Icon shaperectangularList of signs|+-|

Transfer FcnDenominator[1 0.6 0]


StepStep time 0

7.26 Sum

(4)

7.27

7.27

(5)
Start simulation
Simulink SimulationSimulation parametersSolverStop time 15Start simulation
15
Y Y Y-min 0Y-max 2Title 7.28

7.28

(1) (Integrator)(zero-pole)Math OperationsGain-1


(2) GainFlip Block
(3) zero-poleZeros[]Poles[-0.6]

GainGain-1 7.29

7.29

Sinks Out

Workspace I/O ()TimeOutput

toutyout 7.30
plot(tout,yout)

7.30 plot

7.5.3
7.4

(1) Step Transfer Fcn Sum Scope GainDiscrete Discrete


FilterZero-Order Hold
(2) GainZero-Order Hold
(3) Discrete FilterZero-Order HoldSample time 0.1s

(4) 7.31

7.31

(5) Simulink FormatSample time


color
(6) Simulink SimulationSimulation parametersMax step size 0.05s ScopeScope1
7.32

7.32 T=Tk=0.1 (a) d(k)

T=Tk=0.1

(b) y(t)

(7) Discrete FilterSample time 0.6sZero-Order HoldSample timeEditUpdate diagram


Discrete Filter 7.33
T=0.6 Tk=0.1
(8) Discrete Filter Zero-Order HoldSample time 0.6s 7.34

7.33 T=0.6 Tk=0.1 (a) d(k)


7.34 T=0.6 Tk=0.1 (a) d(k)

(b) y(t)
(b) y(t)

T=Tk=0.6

7.5.4

7.5 7.4 7.35

7.35

Ex0705_1.m
% Ex0705_1

T=0.1;

Tk=0.6;

k=0.03;

%Gain

zt1=1.44;zt2=-1.26;zt3=1;zt4=-1;
tf11=6.7;tf12=0.1;tf13=1;
tf21=1;tf22=3;tf23=1

MATLAB
Ex0705_1

7.6

7.6.1

1.
7.6 7.4
EditCreate subsystem 7.36
Subsystem 7.37 In1

7.36

Out1
2.
7.7 7.6 7.6
7.36 Subsystem 7.37
7.38

7.37
7.38

7.39

7.39

7.6.2
1. (Enabled Subsystem)

7.41 (a) Enable

(b) Out1

7.8
Sine waveScopeEnabled Subsystem
Sine waveEnabled Subsystem 7.42(a)
Enabled Subsystem 7.42(b)

2. (Triggered Subsystem)
7.9

7.43 (a)

(b)

Sine wave Scope Triggered Subsystem Sources Pulse


Generator
Pulse GeneratorTriggered Subsystem 7.43(a)
Triggered SubsystemPulse Generator 7.43(b)

7.42 (a)

(b)

3. (Enabled and Triggered Subsystem)


Simulink 0
0

7.6.3
1.
(1)
(2) EditMask subsystem
(3) IconParametersInitializationDocumentation
2.

Icon

Icon 7.44

7.44 Icon

(1) Drawing commands


Drawing commands Examples of drawing commands
plotdisptextport_labelimagepatchcolordrootsdploy fprintf
(2) Icon Options

3. Parameters
Parameters 7.45

7.45 Parameters

(1) Add

Delete

Move up

Move down

(2) Dialog Parameters


Prompt
Variable
typeEditCheckboxPopup
EvaluatetypeEvaluateLiteral 7.6

Evaluate

7.6 Assignment
on

off

type
Edit
Checkbox

1 0

on off

Popup

(3) Options for selected parameter


PopstypePopup
Callback
4. Initialization
Initialization
5. Documentation
Documentation Help Mask typeMask DescriptionMask help
(1) Mask type

(2) Mask Description

(3) Mask help

6.
ApplyUnmask
7.10
zeta wn
(1) zeta wn 7.46
(2) EditCreate Subsystem 7.47

7.46
7.47

Icon Drawing commands


disp('')
plot([0 1 2 3 10],-exp(-[0 1 2 3 10]))

Parameters Add

PrompttypePopupedit

Variablezetawn Popups0 0.3 0.5 0.707 1 2 7.48(a)


Initialization 7.48(b)

7.48 (a) Parameters

(b) Initialization

Documentation 7.48(c)

7.48(c) Documentation

OK 7.49(a) 7.49(b)
zeta wn

7.49 (a)

(b)

7.7 MATLAB Simulink

7.7.1 MATLAB Simulink


1. Simulink
(1)
new_system MATLAB Simulink

new_system(newmodel,option)

newmodeloption LibraryModelModel
(2)
open_system Simulink

open_system(model)

model
(3)
save_system .mdl

save_system(model,)

model
7.11 MATLAB
new_system('Ex0711model')

open_system('Ex0711model')

save_system('Ex0711model','Ex0711')

2.

(1)
add_block

add_block(, 1, 1 2, 2,)
Simulink built-in/Sine Wave

(2)
add_line

add_line(,/, /)
add_line( ,m)
m
7.11 MATLAB
add_block('built-in/Step','Ex0711/Step','position',[20,100,40,120])

add_block('built-in/Sum','Ex0711/Sum','position',[60,100,80,120])

% Sum

add_block('built-in/Transfer Fcn','Ex0711/Fcn1','position',[120,90,200,130])
%
add_block('built-in/Scope','Ex0711/Scope','position',[240,100,260,120]) %
add_line('Ex0711','Step/1','Sum/1')
add_line('Ex0711','Sum/1','Fcn1/1')
add_line('Ex0711','Fcn1/1','Scope/1')
add_line('Ex0711','Fcn1/1','Sum/2')

'position''Ex0711'
7.50

7.50

3.
(1)
7.11
f1=simget('Ex0711')
f1 =
AbsTol: 'auto'
Debug: 'off'
Decimation: 1
DstWorkspace: 'current'
FinalStateName: ''
FixedStep: 'auto'
InitialState: []
InitialStep: 'auto'
MaxOrder: 5
SaveFormat: 'Array'
MaxDataPoints: 1000

%
%
% 1 1
%
%
%
%
%
%
%
%

MaxStep: 'auto'

MinStep: []

OutputPoints: 'all'
OutputVariables: 'ty'

%
%

Refine: 1

RelTol: 0.0010

Solver: 'ode45'

SrcWorkspace: 'base'

Trace: ''

ZeroCross: 'on'

(2)
(3)
7.11 7.3
set_param('Ex0711','StopTime','15')

set_param('Ex0711/Step','time','0')

set_param('Ex0711/Sum','Inputs','+-')

% Sum

set_param('Ex0711/Fcn1','Denominator','[1 0.6 0]') %

7.51

7.51

4.
(1)

delete_block('Ex0711/Scope')

(2)

7.7.2 MATLAB Simulink


sim

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

[t,x,y1,y2,]=sim(model,timespan,options,ut)%
modeltimespan [t0,tf][]
options ut t x y timespan options
ut
7.11 7.50
[t,x,y]=sim('Ex0711',[0,15]);
plot(t,x(:,2))

7.50

7.8 Simulink
Simulink 7.1 (Block and Toolboxes)

(Control System Toolbox)


(Communications Blockset )
(DSP Blockset)
(NCD Blockset)
(Fixed-Point Blockset)
(StateFlow)
(System ID Blocks)
(Neural Network Blockset)

(Fuzzy Logic Toolbox)

Você também pode gostar