Sie sind auf Seite 1von 15

MATLAB Workshop Title Page

Simulink

Simulink Basics Page 1 of 15

JJ II

Mohamed Taha J I

←- ,→
Communication Engineering Department
Full Screen
Princess Sumaya University
mtaha@psut.edu.jo Search

Close

MATLAB
Workshop
Simulink
1 Simulink
• Matlab offers another important tool for mod-
elling and simulation Title Page
Simulink

• Advantages of using simulink include simplicity and


Page 2 of 15
its continuous processing
JJ II
• Simulink handles data exactly the same way as
Matlab does J I

←- ,→
Full Screen

Search

Close

MATLAB
Workshop
Simulink
– Simulink can be started by writing simulink at the
command prompt

Title Page
Simulink

Page 3 of 15

JJ II
J I

←- ,→
Full Screen

Search

Close

MATLAB
Workshop
Simulink
– Simulink contains several libraries

• Simulink library: contains blocks needed to model


and simulate any system Title Page
Simulink
• Blocksets libraries: these libraries are application
Page 4 of 15
specific
JJ II
• Power electronics and power systems toolboxes are
of special concerns J I

←- ,→
Full Screen

Search

Close

MATLAB
Workshop
Simulink
Using Simulink
– To start new model
Title Page
Simulink

Page 5 of 15

JJ II
– Blocks can be dragged and dropped from the library
browser to the new model J I

←- ,→
Full Screen

Search

Close

MATLAB
Workshop
Simulink
Example:
Consider the following system

Title Page
Simulink

Page 6 of 15
– Modeling the system
JJ II
dv(t) J I
f (t) = M + Bv(t)
dt
←- ,→
– Draw the signal flow graph for the system
Full Screen

Search

Close

MATLAB
Workshop
Simulink
In simulink

• f (t) is the force applied to the system, modelled as


step Title Page
Simulink
– from simulink browser, goto simulink →
sources then select step Page 7 of 15

• 1
and B
are gain blocks JJ II
M M

• integrator can be found from simulink → J I


continuous then select integrator
←- ,→
– from simulink browser, goto simulink → math
Full Screen
operations then select Gain
Search
• sum of two signals can be found from simulink
→ math operations then select sum Close

MATLAB
Workshop
Simulink
Configuring the system parameters
• Double click on the gain blocks, set the gain prop-
1 B
erty to M and M Title Page
Simulink
• Double click on the sum, change the signs to +−
Page 8 of 15
• Double click on the step, change the Step time
property to 0 JJ II
J I

←- ,→
Full Screen

Search

Close

MATLAB
Workshop
Simulink
– The system in simulink will look like

Title Page
Simulink

Page 9 of 15

JJ II
J I

←- ,→
Full Screen

Search

Close

MATLAB
Workshop
Simulink
Configuring solver parameters
• on the main toolbar of your model, se-
lect simulation → configuration Title Page
parameters Simulink

– change the stop time to 20 Page 10 of 15

• goto Data import/ export, on the save to JJ II


workspace, check time and output if they are
not already checked J I

←- ,→
Full Screen

Search

Close

MATLAB
Workshop
Simulink
Running simulation
• the variables B and M must be defined, either in
the blocks directly or at the command prompt Title Page
Simulink
• set M = 10 and B = 3.
Page 11 of 15
• from the simulink → sinks select scope. Con-
nect the scope to the output v(t) JJ II

• simulation → start J I

• double click on the scope to view the output ←- ,→


Full Screen

Search

Close

MATLAB
Workshop
Simulink
Export the result into Matlab workspace
– double click on the scope, open the scope parameters
– set the parameters to Title Page
Simulink

variable name : ScopeData Page 12 of 15

format: Array JJ II
J I

←- ,→
Full Screen

Search

Close

MATLAB
Workshop
Simulink
– at the matlab command prompt
plot(ScopeData(:,1),ScopeData(:,2))
– the resulting graph
Title Page
Simulink

Page 13 of 15

JJ II
J I

←- ,→
Full Screen

Search

Close

MATLAB
Workshop
Simulink
Displaying multiple signals on the same
scope
– can be done using a MUX Title Page
Simulink
– from the library browser goto signal
routing and select MUX Page 14 of 15

– drag and drop the MUX in your model JJ II


– double click on the mux and specify number of
J I
inputs
←- ,→
Full Screen

Search

Close

MATLAB
Workshop
Simulink
– let us display the input and output of the previous model
on the same scope
– set number of inputs to 2
Title Page
– connect the input and output to the mux terminals and Simulink
run the simulation
Page 15 of 15

JJ II
J I

←- ,→
Full Screen

Search

Close

MATLAB
Workshop
Simulink

Das könnte Ihnen auch gefallen