Buscar

smlkntro

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes
Você viu 3, do total de 11 páginas

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes
Você viu 6, do total de 11 páginas

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes
Você viu 9, do total de 11 páginas

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Prévia do material em texto

MECH 411/501
Introduction to SIMULINK and Animations
Jim Dabney
jdabney@rice.edu
Rice Extension 3619
1. Block Diagrams
• Graphical representation of differential equations
• Example - loan balance
where , , .
2. Starting SIMULINK
• Start MATLAB
• Enter VLPXOLQN at the MATLAB prompt
• Current SIMULINK directory is the same as the current MATLAB directory
• Create new model window with File:New
x
·
rx p–=
r 0.01= p 100= x 0( ) 2000=
1
3. Adding Blocks
• Drag blocks from block libraries
• Sources - produce signals. Source blocks have outputs but no inputs
• Sinks - display signals. Inputs but no outputs. Examples are Scope, Display, To Work-
space.
• System blocks - inputs and outputs.
• Copy blocks from within model window dragging while depressing the Control key or 
Right dragging.
4. Connecting Blocks
• Draw signal lines. Drag from output port (>) to input port (<).
• Edit signal lines. Drag segment or vertex.
5. Configuring Blocks
• Double click on block to open block dialog box.
• Set numeric parameters - Gain, initial condition of integrator. Note the initial condition 
of an integrator block is the initial value of the block output.
• Configure Sum blocks using the list of signs. First sign is top input to block 
2
.
• Edit block names. Click on name and edit. Each block must have unique name.
• Choose Format:Flip Block to flip a block horizontally.
• For help on a particular block, use the on-line Block Browser. Click on the block Help 
button or File:Show Browser.
6. Running a Simulation
• Set Start time, Stop time in the Simulation:Parameters dialog box. This must be set 
using the model window menu bar (not the SIMULINK block library window menu 
bar). 
(a) Sum block dialog box (b) Corresponding Sum block
Figure 1: Configuring Sum block
3
 
• Simulation:Start to start the simulation. Menu changes to Stop while simulation is 
running. There are also Pause and Resume selections.
7. SIMULINK Examples
• First-order system
 
Figure 2: Simulation:Parameters dialog box
Figure 3: SIMULINK model of first order system
x
·
rinterestx p– ayment=
4
• Second-order system
• Coupled second-order systems
 
Figure 4: SIMULINK model of second-order system
x
··
c
m
----x
·
–
k
m
----x–=
z··
c1
m1
------ z· y·–( )
k1
m1
------ z y–( )––=
y··
c1
m2
------ y· z·–( )–
c2
m2
------y·–
k1
m2
------ y z–( )–
k2
m2
------y–=
5
 
8. MATLAB Animations
• First, draw figure window
KROG RQ so that figure isn’t cleared when objects are added
Save handles of objects that will change (for example change position)
 ILJXUH
 D[LV�>�������@��
 KROG RQ �
 [G >�������������������@ �
 \G >�������������������@ �
 KG� ILOO�[G�\G�
U
� �
• Animate figure in a loop. For example, to animate the object above:
IRU W ��������
VHW�KG��
;'DWD
�[G����
VLQ�W��
<'DWD
�\G����
FRV�W���
SDXVH����� �
HQG
Figure 5: Coupled second-order systems
6
• Animation example.
This example produces the display in Figure 6. The MATLAB differential equation 
function is shown in Figure 7. The script M-file is shown in Figure 8. 
Figure 6: Animation figure
IXQFWLRQ [BGRW DQP�BGRW�W� [�
� &RPSXWH WKH GHULYDWLYH IRU WKH DQLPDWLRQ P�ILOH H[DPSOH
�
� 6WDWH YHFWRU
� [��� $QJOH RI GLVN FHQWHU UHODWLYH WR WKH YHUWLFDO
� [��� 5DWH RI FKDQJH RI GLVN DQJOH
P � �
U � �
5 �� �
J ��� � � $FFHOHUDWLRQ GXH WR JUDYLW\
,F �����
P
UA� �
[BGRW ]HURV��� �� �
[BGRW��� [��� �
[BGRW��� �P
J
U
VLQ�[������P
U
�5�U��,F
��5�U��U�� �
Figure 7: Animation example differential equation function M-file
� 0(&+ ���
� -LP 'DEQH\ ��������
Figure 8: Animation M-file
7
� $QLPDWLRQ H[DPSOH
� 7KLV SURJUDP GHPRQVWUDWHV DQLPDWLRQ XVLQJ VWDQGDUG P ILOHV �DV RSSRVHG WR
� 6LPXOLQN V�ILOHV��
� 6\VWHP SDUDPHWHUV
P � �
U � �
5 �� �
J ��� � � $FFHOHUDWLRQ GXH WR JUDYLW\
� 6HW XS WKH LQWHJUDWLRQ SDUDPHWHUV DQG LQLWLDO FRQGLWLRQV
W� � � � 6WDUW DW WLPH �
WVWHS ��� � � 6SDFLQJ EHWZHHQ RXWSWXW SRLQWV
WI �� � � 6WRSSLQJ WLPH
[� >SL��� �@� � ,QLWLDO SRVLWLRQ DQG YHORFLW\
� 1H[W� SHUIRUP WKH LQWHJUDWLRQ�
>W� [@ RGH���©DQP�BGRWª� >W��WVWHS�WI@� [�� �
� 3ORW WKH UHVXOWV RI WKH VLPXODWLRQ
ZKLWHEJ�
Z
� � � 0DNH VXUH ZH JHW D ZKLWH EDFNJURXQG
VXESORW��������
SORW�W�[�����
����SL� �
D[LV�>W��WI��[����
����SL�[����
����SL@� �
JULG�
WLWOH�
7UDMHFWRU\ IRU $QLPDWLRQ ([DPSOH
� �
[ODEHO�©7LPHª��
\ODEHO�
'LVSODFHPHQW �GHJ�
��
VXESORW��������
SORW�W�[�����
����SL� �
D[LV�>W��WI��PD[�[������
����SL�PD[�[������
����SL@� �
JULG�
[ODEHO�
7LPH
��
\ODEHO�
9HORFLW\
��
SDXVH � � 0XVW SUHVV HQWHU WR FRQWLQXH
FORVH �
� 1H[W� VKRZ WKH PRWLRQ RI WKH GLVN
Figure 8: Animation M-file
8
� 6WDUW E\ PDNLQJ WKH WURXJK� 7KH VHTXHQFH RI SRLQWV �[S�Q��\S�Q��
� GHILQHV WKH RXWOLQH RI WKH WURXJK
T U �
WKS ������SL �
[S 5
FRV�WKS��
\S �5
VLQ�WKS� �
[S >[S��5���5�T����5�T���5�T�� �5�T��5@ �
\S >\S�������5�T����5�T�����@ �
FOB[ >���@ �
FOB\ >���5@ �
� 0DNH WKH GLVN WKDW ZLOO UROO EDFN DQG IRUWK
WKS ���������
SL �
[G U
FRV�WKS��
\G U
VLQ�WKS� �
� 'R WKH VKRZ
>QURZ�QFRO@ VL]H�[� �
KG ILOO�[S�\S�
E
�� � 'UDZ WURXJK� 1RWH WKDW §ILOO¨ LV DERXW WKH
� VDPH DV SORW� EXW UHTXLUHV WKH FRORU LQ
� VLQJOH TXRWHV �©Eª PHDQV PDNH LW EOXH��
KROG RQ � � 7KLV NHHSV WKH WURXJK RQ WKH VFUHHQ
VHW�KG�
HUDVHPRGH
�
QRQH
�� � 7KLV SUHYHQWV LW IURP UHGUDZLQJ HDFK WLPH
D[LV�
HTXDO
��D[LV�
RII
�� � 0DNHV FRUUHFW DVSHFW DQG QR D[LV
KG� SORW�FOB[�FOB\�ªE�ª�� � 'UDZ WKH FHQWHUOLQH
VHW�KG��
HUDVHPRGH
�
QRQH
��
IRU M ��QURZ � 2QFH IRU HDFK WLPH VWHS
WKHWD [�M��� �
[F �5�U�
VLQ�WKHWD�� � )LQG FHQWHU RI GLVN
\F � �5�U�
FRV�WKHWD� �
SVL WKHWD
�5�U��U �
[PBF U
VLQ�SVL� � � )LQG UHODWLYH SRVLWLRQ RI LQGH[ PDUN
\PBF U
FRV�SVL� �
[P [F � [PBF � � 7UDQVODWH PDUN
\P \F � \PBF �
Figure 8: Animation M-file
9
9. SIMULINK Animation Toolbox
• Copy Simulation Animation block into the model window 
• Combine signals needed to determine animation state using a Mux block (multiplexer)
LI�M �� � )LUVW WLPH WKURXJK GUDZ GLVN� KG� LV WKH
� §KDQGOH¨ RI WKH GLVN� KG� LV WKH KDQGOH RI
� WKH LQGH[ PDUN�
KG� SORW�[G�[F� \G�\F� 
U
� � � 'UDZ GLVN DQG PDUN
KG� SORW�>[F�[P@�>\F�\P@�
N�
��
HOVH � )RU HDFK VXEVHTXHQW VWHS� ZH PRYH WKH GLVN
� �KG�� DQG LQGH[ PDUN �KG��
� VHW LV WKH 0$7/$% FRPPDQG WR FKDQJH D
� SURSHUW\ RI D JUDSKLFV REMHFW�
VHW�KG��
;'DWD
�[G�[F�� � 0RYH WKH GLVN WR LWV QHZ ORFDWLRQ
VHW�KG��
<'DWD
�\G�\F��
VHW�KG��
;'DWD
�>[F�[P@�� � 0RYH WKH LQGH[ PDUN
VHW�KG��
<'DWD
�>\F�\P@��
HQG
SDXVH����� � � <RX PXVW SDXVH DIWHU HDFK VWHS RU 0$7/$%
� ZLOO RQO\ GUDZ WKH ODVW IUDPH
HQG �
KROG RII � � 5HOHDVH WKH JUDSK
Figure 9: SIMULINK model with Animation block
Figure 8: Animation M-file
10
• Double click on Simulation Animation block to open animation window, Figure 10. 
• Drag animation objects from palette at left edge of animation window
• Set object properties using input vector. First input (top signal entering Mux) is referred 
to as u(1), next signal as u(2), etc.
• Set animation figure properties using the menu bar of the animation window. Usually 
set Autoscale to off.
• When you close the animation window, a file save dialog box will be displayed.
• To use an existing animation (one previously saved for a particular animation block), 
double click on the block. A menu will be displayed allowing you to choose to use the 
existing animation or start a new one.
Figure 10: SIMULINK animation window
11MECH 411/501 Introduction to SIMULINK and Animatio...
	1. Block Diagrams
	2. Starting SIMULINK
	3. Adding Blocks
	4. Connecting Blocks
	5. Configuring Blocks
	Figure 1 :nullConfiguring Sum block
	6. Running a Simulation
	Figure 2 :nullSimulation:Parameters dialog box
	7. SIMULINK Examples
	Figure 3 :nullSIMULINK model of first order system
	Figure 4 :nullSIMULINK model of second-order system
	Figure 5 :nullCoupled second-order systems
	8. MATLAB Animations
	Figure 6 :nullAnimation figure
	Figure 7 :nullAnimation example differential equation...
	Figure 8 :nullAnimation M-file
	9. SIMULINK Animation Toolbox
	Figure 9 :nullSIMULINK model with Animation block
	Figure 10 :nullSIMULINK animation window

Outros materiais