La descarga está en progreso. Por favor, espere

La descarga está en progreso. Por favor, espere

Introducción a Simulink

Presentaciones similares


Presentación del tema: "Introducción a Simulink"— Transcripción de la presentación:

1 Introducción a Simulink
MATLAB Versión 4.2c.1 SIMULINK Versión 1.3c

2 Indice  Qué es Simulink Cómo crear un modelo
Cómo ejecutar la simulación de un modelo At the most basic level, building a model involves four steps: collecting and connecting blocks, simulating the system, analyzing results, and refining the model. Each of these steps will usually be done numerous times over the lifetime of a model. During this course, we are going to look at each of these steps in detail. We will first start with Collecting and connecting blocks. Later on we will simulate a few different types of models, and then we will work with oneof the models to analyze results. Finally we will look at some advanced features which will help you to refine your models.

3 ¿ Qué es Simulink ? MATLAB SIMULINK
Es una herramienta interactiva, para modelar y analizar sistemas dinámicos, basada en diagramas de bloques. Está fuertemente acoplada con MATLAB Toolboxes: Control, Señales Estadísticas, Finanzas,... Blocksets Stateflow 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. MATLAB Real Time Workshop SIMULINK See: Using SIMULINK Pages: 1-2 and 1-3

4 Crear un modelo Editar un modelo Abrir la ventana de un nuevo modelo
Conectar los bloques Añadir bloques Cambiar el tamaño de los bloques Modificar etiquetas y añadir anotaciones Parametrizar los bloques Guardar un modelo (formato M-File) Abrir un modelo desde Matlab See: Using SIMULINK Pages: Chapters 2 and 3

5 Abrir la ventana de un nuevo modelo
Escribiendo simulink se inicia el programa. » simulink Seleccionado, en Simulink, en el menú File el submenú New se crea la ventana de un nuevo modelo See: Using SIMULINK Pages: 3-3

6 doble click en un icono para desplegar los bloques de
Añadir bloques Hacer doble click en un icono para desplegar los bloques de la librería 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. Arrastrar los bloques deseados dentro de la ventana del modelo simulink See: Using SIMULINK Pages: 3-4

7 Conectar los bloques Para añadir una línea:
Arrastrar, pulsando el botón derecho del ratón, desde una salida, o desde una entrada, de alguno de los bloques See: Using SIMULINK Pages: 3-15 to 3-19

8 Cambiar el tamaño de los bloques
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

9 Modificar etiquetas y añadir anotaciones
Hacer click en la etiqueta y editarla Etiquetas Anotaciones Hacer click en el fondo y escribir el texto

10 Parametrizar los bloques
Hacer doble click sobre el bloque que se desea parametrizar

11 Crea el fichero del modelo:
Guardar un modelo Crea el fichero del modelo: orden_1.m Abrir el modelo desde Matlab See: Using SIMULINK Pages: 3-33, Appendix B

12 Ejecutar una simulación
Poner los parámetros de la simulación 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

13 Poner los parámetros de la simulación
Simular Poner los parámetros de la simulación 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 Pages: 4-6 to 4-18

14 Parámetros de simulación ( de un sistema lineal )
Método de integración: 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 Pages: 4-6 to 4-12c

15 Ejecutar una simulación desde la ventana del modelo
Salida del bloque Auto-Scale Graph

16 Poner y sacar valores en / desde los modelos (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 Pages: 4-14 to 4-16

17 Utilizar en Matlab los valores obtenidos en la simulación
Después de ejecutar la simulación en Simulink

18 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 Matlab Simulink » T = 2 ; » K = 1 ; The MATLAB workspace is a cauldron into which anything can be dumped including SIMULINK data. Espacio de trabajo T = 2 t = 0:0.01:10 K = 1 pi= See: Using SIMULINK Pages: 3-12

19 Simular desde la línea de comandos
¿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 Pages: 4-21 to 4-28

20 Parámetros de simulación del modelo orden_1.m
Simular un modelo Parámetros de simulación del modelo orden_1.m Modelo: orden_1.m Simulación desde la ventana del modelo (desde el menú correspondiente) : Se utilizan los parámetros definidos en el modelo Simulación desde la línea de comandos de MATLAB: Se utilizan otros parámetros: explícitos unos y por defecto otros

21 Simular desde la línea de comandos ( los métodos más sencillos )
Simular un modelo utilizando todos los parámetros. [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 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] ) 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. Simular un modelo indicando únicamente el tiempo final. linsim ( modelo, tfinal) See: Using SIMULINK Pages: 4-21 to 4-28

22 Ejemplos desde la línea de comandos
Parámetros de simulación del modelo desde MATLAB Modelo: orden_1.m Simulación indicando el tiempo final ( 10 ) y los intervalos de integración máximo y mínimo ( 0.1 ) >> tiempo = linsim ('orden_1',10 ,[ ],[0, 0.1, 0.1]) Simulación indicando únicamente el tiempo final ( 10 ) >> tiempo = linsim ('orden_1', 10)

23 FIN DE LA PRESENTACIÓN


Descargar ppt "Introducción a Simulink"

Presentaciones similares


Anuncios Google