introducción a simulink

23
1 Introducción a Simulink Fabián López - Curso 2000/2001 Introducción a Simulink MATLAB Versión 4.2c.1 SIMULINK Versión 1.3c

Upload: slavenko-andre

Post on 17-Sep-2015

237 views

Category:

Documents


1 download

DESCRIPTION

Simulador

TRANSCRIPT

Introducción a Simulink
*
basada en diagramas de bloques.
Está fuertemente acoplada con MATLAB
MATLAB
Blocksets
Stateflow
Toolboxes:
Control,
Señales
Estadísticas,
Finanzas,...
SIMULINK
What is SIMULINK?
The course is about SIMULINK, but to understand SIMULINK, you first need to understand something about the environment that SIMULINK lives in: MATLAB
The main thing to notice about the picture above is that SIMULINK belongs not at the center of the diagram, but off to the side. MATLAB solidly occupies center stage. So our question about SIMULINK leads to another question: What is MATLAB? I prefer to think of SIMULINK as a child of MATLAB. In order to work, SIMULINK needs MATLAB. The converse is not true.
See: Using SIMULINK
Conectar los bloques
Modificar etiquetas y añadir anotaciones
Parametrizar los bloques
See: Using SIMULINK
*
Escribiendo simulink se inicia el programa.
» simulink
See: Using SIMULINK
la librería
Arrastrar los bloques deseados dentro de la ventana del modelo simulink
You can get the Signal Generator from the Sources library. Likewise, pull the Gain block from the Linear library and the Scope block from the Sinks library. All you need to do is double click on the block library and then drag the blocks that you need into the new untitled model window.
See: Using SIMULINK
desde una salida,
See: Using SIMULINK
Tras seleccionar el bloque, aparecen en él los puntos,
desde los cuales se puede arrastrar para cambiar el tamaño del bloque
Posteriormente se pueden mover el bloque
para que las líneas de conexión queden rectas
*
Etiquetas
Anotaciones
Hacer click en el fondo y escribir el texto
*
*
orden_1.m
See: Using SIMULINK
Ejecutar una simulación desde la ventana del modelo
Poner y sacar valores en/desde los modelos
Utilizar en Matlab los valores obtenidos en la simulación
Variables definidas en Matlab y Simulink
Simular desde la línea de comandos
*
Simular
This dialog box is as important to the success of your simulation as anything in the block diagram. It controls the major simulation parameters that are responsible for propagating your system through time.
See: Using SIMULINK
Linsim
It is very important to understand the settings that you put in here. For instance, create a new model with a Signal Generator that feeds into a Scope. The Signal Generator frequency should be 1 Hz. Now set the stop time of the system to be 50 seconds, use a variable step solver with a max step size set to auto. What do you expect to happen? It is probably not what actually happens. What actually happens is that you get an almost completely flat line at 0. This is because your max step size will be 50/50 or 1 second. Your frequency of the Signal Generator is 1 Hz (or 1 cycle per second). That means that your output will be very close to zero for the entire simulation.
See: Using SIMULINK
Salida del bloque Auto-Scale Graph
*
(desde / hacia el espacio de trabajo)
It is possible to get data into and out of models using a number of different methods. If you use the Parameters Dialog Workspace I/O page to do this for you, then the top level of your SIMULINK diagram must contain an appropriate number of inports and outports.
See: Using SIMULINK
Después de ejecutar la simulación en Simulink
*
Variables definidas en MatLab y Simulink
Tanto desde la ventana de Matlab como la de Simulink se “ve” el mismo Workspace o Espacio de trabajo
» T = 2 ;
» K = 1 ;
K = 1
pi=3.14159...
t = 0:0.01:10
T = 2
trabajo
The MATLAB workspace is a cauldron into which anything can be dumped including SIMULINK data.
See: Using SIMULINK
¿Por qué simular desde la línea de comandos?
Repetir de manera automática las simulación
Ajustar o sintonizar los parámetros
Why simulate from the command line? This is a good question. Essentially the answer is that if you want to run repeated simulations and not have to wait around to run the simulation again and again then simulation from the command line is probably what you want. Also, if you are varying parameters ina model and analyzing the results from the variations, then it is much easier to set up a for loop to step through each parameter automatically.
See: Using SIMULINK
(desde el menú correspondiente) :
*
( los métodos más sencillos )
Simular un modelo indicando el tiempo inicial, final y los intervalos de integración máximo y mínimo.
linsim ( modelo, tfinal, x0, [tol, minstep, maxstep] )
Simular un modelo indicando únicamente el tiempo final.
linsim ( modelo, tfinal)
[t, x, y] = linsim (modelo, tfinal, x0,[tol, minstep, maxstep],...)
El tiempo t, el estado x y la salida y son vectores que son retornados
por la simulación.
Si no se asignan los resultados a variables, se obtienen gráficamente
The syntax for running a simulation from the command line has changed with SIMULINK 2. There is now one command for all of the solvers and controlling solver settings is much easier.
See: Using SIMULINK
Modelo:
orden_1.m
y los intervalos de integración máximo y mínimo ( 0.1 )
>> tiempo = linsim ('orden_1',10 ,[ ],[0, 0.1, 0.1])
Parámetros de simulación
>> tiempo = linsim ('orden_1', 10)