How Work Simulink
ECE743
Jin-Woo Jung,
Ph. D. Student and GTA
Advisor: Prof. Ali Keyhani
January 21, 2005
Department of Electrical and Computer Engineering
The Ohio State University
1 /36
ECE743
Features of Matlab and Simulink
Matlab (*.m):
Only text code (Not easy to model complicated systems)
Easy to edit figures
Simulink (*.mdl):
Schematic (Easy to model complicatedsystems)
Not easy to change parameters
Can not edit figures
Matlab (*.m) + Simulink (*.mdl): Best choice
Schematic: Simulink
Easy to change parameters: Matlab (m file for parameter initialization)
Edit figures: Simulink (“To Workspace”) ⇒ Matlab (m file for plot)
2 /36
ECE743
Available Simulink Toolboxes (version. 6.5)
Simulink
Neural Network Blockset
Aerospace BlocksetReal-Time Windows Target
CDMA Reference Blockset
Real-Time Workshop
Communications Blockset
Report Generator
Control System Toolbox
S-function demos
DSP Blockset
SimMechanics
Gauges Blockset
SimPowerSystems
Embedded Target for Motorola MCP555
Simulink Extras
Embedded Target for TI C6000 DSP
System ID Toolbox
Fixed-Point Blockset
Virtual Reality ToolboxFuzzy Logic Toolbox
xPC Target
MPC Blocks
NCD Blockset
Stateflow
♦
: Available toolboxes at ECE Computer Lab.
ECE743
3 /36
1. Current Directory
Click “Browser for folder”
1). Change “Current directory”
4 /36
ECE743
2. Starting “Simulink”
1). Click “Simulink”
Then, Simulink Library Browser
5 /36
ECE743
3. Open “A new file”
1). Click “Create anew model”
Then, a new Simulink file
6 /36
ECE743
4. Building “System” (1)
Find ‘’Block‘’ when you know “block’s name”
1). Type block’s name and then drag it to a new file
“Press a right button on a mouse”
7 /36
“Double click your model”
Click “Help” to set up parameters ECE743
4. Building “System” (2)
Find ‘’Block‘’ when you don’t know “block’s name”
1). Click“Simulink Help”
Then, type the text for model search
8 /36
This is model name
ECE743
5. Set up “Model properties”
Set up m files for parameter initialization and plot (later)
1). Click “Model properties”
Then, type file names: Initialization.m and Plot.m
9 /36
ECE743
6. Start “Simulation” (1)
Set up “Simulation parameters”
Then, change “Stop time”
1). Click “Simulationparameters”
10/36
ECE743
6. Start “Simulation” (2)
Start Simulation
1). Click “Start simulation”
11/36
ECE743
7. Example for Matlab/Simulink
Example 1:
where: Lp = 0.1 H, Ls = 0.2 H, Rp = 1 Ω, Rs = 2 Ω, R1 = 1 Ω, Mi = 0.1 H,
C = 1 µF, and V = 10 V (Step Input)
Simulate the dynamic response of i1, i2, and Vc and
plot the results on the same page.
12/36
ECE743
7.Example 1
Four different Methods
Case 1: Only Matlab
Case 2: Matlab + Simulink: S-Function
1. S-function: “asglpr3b.m”
2. Simulink: “Example_1.mdl”
3. Plot: Plot_1.m
Case 3: Matlab + Simulink: Not S-Function
1. Parameter initialization: “Initialization.m”
2. Simulink: “Case_3.mdl”
3. Plot: Plot_1.m
Case 4: Matlab + Simulink: “SimPowerSystems”
1. Parameter initialization:“Para_Initial.m”
2. Simulink: “Case_4.mdl”
3. Plot: Plot_1.m
♦ “Note that all files should be under current directory”
13/36
ECE743
7. Example 1 − Case 1 – (1)
Case 1: Only Matlab – (1)
% Only Matlab code - Example 1 - Case 1
clear all
Lp = 0.1;
Ls = 0.2;
Mi = 0.1;
Rp = 1;
Rs = 2;
R1 = 1;
C = 1e-6;
V = 10;
alpha = 0.1;
R = [-Rp 0 0; 0 -(Rs+R1) -1; 0 1 0]
D = [1;0;0]
L = [(Lp+Mi) -Mi0; -Mi (Ls+Mi) 0; 0 0 C]
Linv = inv(L);
A = Linv*R;
B = Linv*D;
X = [0;0;0];
U = V;
14/36
ECE743
7. Example 1 − Case 1 – (2)
Case 1: Only Matlab – Matlab code continued - (2)
T = 0.0001; % time step
for n = 1:10000
% Trapezoidal Integration
n1(n) = n;
Xest = X + T*(A*X + B*U);
Xdotest = A*Xest + B*U;
alpha1 = 1 + alpha;
alpha2 = 1 - alpha;
term1 = alpha1*Xdotest;...
Regístrate para leer el documento completo.