0% found this document useful (0 votes)
54 views53 pages

Application Software Course Control & Simulink: By: Mahdi Akbari 09, November

This document provides an overview of using MATLAB and Simulink for modeling and simulating dynamic systems. It describes how to perform various tasks like defining transfer functions and calculating roots, creating Simulink models, and simulating and analyzing models. Key functions and blocks covered include tf, roots, step response, bode plots, and feedback systems. The document also provides examples of creating and working with Simulink models, including adding blocks, making connections, creating subsystems, and running simulations.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views53 pages

Application Software Course Control & Simulink: By: Mahdi Akbari 09, November

This document provides an overview of using MATLAB and Simulink for modeling and simulating dynamic systems. It describes how to perform various tasks like defining transfer functions and calculating roots, creating Simulink models, and simulating and analyzing models. Key functions and blocks covered include tf, roots, step response, bode plots, and feedback systems. The document also provides examples of creating and working with Simulink models, including adding blocks, making connections, creating subsystems, and running simulations.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 53

Application Software Course Control & Simulink

By: Mahdi Akbari 09,November


1

Roots
G ( s) s 5 2s 4 3s 3 4s 2 5s 6
>> roots([1,2,3,4,5,6]) ans = 0.5517+ 1.2533i 0.5517- 1.2533i -1.4918 -0.8058+ 1.2229i -0.8058- 1.2229i
2

Symbolic Mathematic
Sym: Create symbolic object >> x=sym(x) Syms: Shortcut for creating multiple symbolic objects >> syms x,y

Symbolic Mathematic

Example

>> syms s >> f = (5*s^2 + 3*s +6)/(s^4 + 3*s^3 + 7*s^2 + 9*s +12); >> ilaplace(f )

Transfer Functions
s5 G( s) 4 3 2 s 2s 3s 4s 5
>> num=[1,5]; >> den=[1,2,3,4,5]; >> G=tf(num,den)

Transfer Functions

>> den=conv(conv(conv([1,3,1],[1,3,1]),[1,6]),[1,6,5,3]); >> num=6*[1,5]; >> G=tf(num,den)

Transformation of System Model (Steady State)


. x Ax Bu y Cx Du

>> G=ss(A,B,C,D)

Example

>> A=[2.25, -5, -1.25, -0.5; 2.25, -4.25, -1.25, -0.25; 0.25, -0.5, -1.25,-1; 1.25, 1.75, -0.25, -0.75]; >> B=[4, 6; 2, 4; 2, 2; 0, 2]; >> C=[0, 0, 0, 1; 0, 2, 0, 2]; >> D=zeros(2,2); >> G=ss(A,B,C,D)

Transformation of System Model


Y ( s) num C ( SI A) 1 B D u ( s) den

. x Ax Bu y Cx Du

[A, B, C, D] = tf2ss (num, den) [num , den] = ss2tf (A, B, C, D)

10

Zero-pole-gain Description

>> KGain=6; >> Z=[-1.9294; -0.0353+0.9287j; -0.0353-0.9287j]; >> P=[-0.9567+1.2272j; -0.9567-1.2272j; 0.0433+0.6412j; +0.04330.6412j]; >> G=zpk(Z,P,KGain)

11

step responses
>> step (num,den) >> step (A,B,C,D) for find:
MP Rise time Fall time Over shoot
12

Form 3:
>> [y,x,t] = step (num,den,t) >> plot(t,y)

13

impulse responses
C (s) 1 R( s) s 1

For impulse responses: R(s)=1


1 s 1 C (s) G(s) ( ) s 1 s 1 s C (s) s 1 s 1 u (s) s

Step ( s G(s) )
14

impulse responses
>> impulse (num, den)

15

Ramp responses
Step ( G(s)/S )

16

Feedback

>> Gt=feedback(G,H) >> syms g1 g2 % declare symbolic variables >> Gt=feedback(g1,g2,1); %Defult: negative feedback >> pretty(Gt)

17

Example:

>> G1=tf(1,[1,2,1]); >> G2=tf(1,[1,1]); >> G=feedback(G1,G2) %for negative feedback

>> G=feedback(G1,G2,+1) % for positive feedback

18

>>[r, p, k] = residue(num, den)

19

Root Locus Plots

[r, k] = rlocus (num, den) [r, k] = rlocus (num, den, k) [r, k] = rlocus (A, B, C, D) [r, k] = rlocus (A, B, C, D, K)

20

Example
>> num = [0 0 0 1]; >> den = [1 5 9 0]; >> rlocus(num, den);

21

Bode Diagrams
bode(num, den) bode(num, den, W) bode(A, B, C, D) (3.36) bode(A, B, C, D, W) [mag, phase, w] = bode (num, den) [mag, phase, w] = bode (num, den, w) [mag, phase, w] = bode (A, B, C, D) [mag, phase, w] = bode (A, B, C,D, w) [mag, phase, w] = bode (A, B, C, D, iu, w)
22

Example
>> %Bode diagram >> num= [29.125 33.2025 9.4627]; >> den= [0 1 0]; >> bode (num, den)

23

Nyquist Plots
nyquist (num, den, w) nyquist (A, B, C, D) nyquist (A, B, C, D, w) nyquist (A, B, C, D, iu, w) [re, im, w] = nyquist (num, den) [re, im, w] = nyquist (num, den, w) [re, im, w] = nyquist (A, B, C, D) [re, im, w] = nyquist (A, B, C, D, w) [re, im, w] = nyquist (A, B, C, D, iu, w)
24

Example
>> z = [ 1 3 + 7*i 3 7*i]; >> p = [ 1 3 5 3 + 7*i 3 7*i]; >> k = 30; >> nyquist (num, den)

25

What Is Simulink?
Simulink is a software package for modeling, simulating, and analyzing dynamical systems. It supports linear and nonlinear systems, modeled in continuous time, sampled time, or a hybrid of the two.

26

How to open simulink


Click on this item

27

create a model
To create the model, first type simulink in the MATLAB command window. On Microsoft Windows, the Simulink Library Browser appears.

28

Open new window


Click on New Model button

Simulink opens a new model window.


29

Model Editor

30

View Command History


Back =(Displays the previous view in the view history.Forward ) forward=( Displays the next view in the view history.Go To Parent )

Go To Parent=Opens, if necessary, the parent of the current subsystem and brings its window to the top of the desktop.

31

Building a Simple Model


This example shows you how to build a model using many of the model building commands and actions you will use to build your own models The model integrates a sine wave and displays the result, along with the sine wave. The block diagram of the model looks like this

32

Create example model


1. 2. 3. 4. To create this model, you will need to copy blocks into the model from the following Simulink block libraries: Sources library (the Sine Wave block) Sinks library (the Scope block) Continuous library (the Integrator block) Signals & Systems library (the Mux block)

33

first expand the Library Browser tree to display the blocks in the Sources library. Do this by clicking first on the Simulink node to display the Sources node Sources node to display the Sources library blocks. Finally right click on the Sine Wave node to select the Sine Wave

34

Copy the rest of the blocks in a similar manner from their respective libraries into the model window

35

With all the blocks copied into the model window, the model should look something like this.

Now its time to connect the blocks. Hold down the mouse button and move the cursor to the top input port of the Mux block. Notice that the line is dashed while the mouse button is down and that the cursor shape changes to double-lined cross hairs as it approaches the Mux block.

36

Now release the mouse button. The blocks are connected

Press and hold down the Ctrl key. Press the mouse button, then drag the pointer to the Integrator blocks input port or over the Integrator block itself.

37

Finish making block connections. When youre done, your model should look something like this.

38

39

Now, open the Scope block to view the simulation output. Keeping the Scope window open, set up Simulink to run the simulation for 10 seconds. the simulation parameters by choosing Parameters from the Simulation menu. On the dialog box that appears notice that the Stop time is set to 10.0 (its default value)

40

Choose Start from the Simulation menu and watch the traces of the Scope blocks input.

41

Model Viewing Shortcuts

42

Zooming Block Diagrams


Select Zoom In from the View menu (or type r) to enlarge the view.Select Zoom Out from the View menu (or type v) to shrink the view. Select Fit System To View from the View menu (or press the space bar) to fit the diagram to the view. Select Normal from the View menu (or type 1) to view the diagram at actual size.

43

colors
Simulink allows you to specify the foreground and background colors of any block select Screen color from the Simulink Format menu

44

Connecting Blocks
Connecting Two Blocks To auto connect two blocks: Select the source block. Hold down Ctrl and left-click the destination block.Simulink connects the source block to the destination block

When connecting two blocks, Simulink draws as many connections as possible between the two blocks as illustrated in the following example.

45

Connecting Groups of Source Blocks


Simulink can connect a group of source blocks to a destination block or a source block to a group of destination blocks.To connect a group of source blocks to a destination block: Select the source blocks. Hold down Ctrl and left-click the destination block.

46

connect a source block to a group of destination blocks


Select the destination blocks.

Hold down Ctrl and left-click the source block.

47

Moving a Line Segment


To move a line segment: Position the pointer on the segment you want to move.

Press and hold down the left mouse button.

Drag the pointer to the desired location.


48

Inserting Blocks in a Line


To insert a block in a line: Position the pointer over the block and press the left mouse button.

Drag the block over the line in which you want to insert the block.

Release the mouse button to drop the block on the line. Simulink inserts the block where you dropped it.

49

Disconnecting Blocks
To disconnect a block from its connecting lines, hold down the Shift key, then drag the block to a new location.

50

Creating Subsystems
As your model increases in size and complexity, you can simplify it by grouping blocks into subsystems. Using subsystems has these advantages: It helps reduce the number of blocks displayed in your model window. It allows you to keep functionally related blocks together

51

Creating a Subsystem by Adding the Subsystem Block


To create a subsystem before adding the blocks Copy the Subsystem block from the Ports & Subsystems library into your model. Open the Subsystem block by double-clicking it. In the empty Subsystem window, create the subsystem. For example, the subsystem shown includes a Sum block and inport and Outport blocks to represent input to and output from the subsystem.

52

Creating a Subsystem by Grouping Existing Blocks


If your model already contains the blocks you want to convert to a subsystem, you can create the subsystem by grouping those blocks: Enclose the blocks and connecting lines that you want to include in the subsystem within a bounding box. You cannot specify the blocks to be grouped by selecting them individually or by using the Select All command. Choose Create Subsystem from the Edit menu.

If you open the Subsystem block, Simulink displays the underlying system, as shown below.

53

You might also like