Docsity

Simulink MATLAB-Computational Physics-Lecture Slides, Slides of Computational Physics

Partial preview of the text

Download Simulink MATLAB-Computational Physics-Lecture Slides and more Slides Computational Physics in PDF only on Docsity!

MATLAB/SimuLink

In this lecture

  • Introduction to MATLAB/SimuLink
  • SimuLink
    • Block diagram model and mathematical models to depict dynamic system
    • Work with blocks and signals
    • Run and debug

Introduction

  • Where to use MATLAB
    • Math and computation
    • Algorithm development
    • Data acquisition
    • Modeling, simulation, and prototyping
    • Data analysis, exploration, and visualization
    • Scientific and engineering graphics
    • Application development, including graphical user interface building

Introduction

  • MATLAB system:
    • Integrative Development Environment (IDE)
    • MATLAB Mathematical Function Library
      • Including Bassel functions and fast Fourier Transformation
    • MATLAB Language
      • high-level matrix/array language
      • object-oriented
    • Graphics
      • display vectors and matrices as graphs
    • API
      • C/Fortran program can interact with MATLAB

Introduction--Desktop

  • Command Window
    • enter variables
    • run functions/M-files
      • Command History
        • View statements
        • Save: diary('filename')

Introduction -- Desktop

  • Editor/Debugger

MATLAB View

Or just type simulink as shown here to start simulink

To start Simulink, you must first start MATLAB.

Consult your MATLAB documentation for more information.

You can then start Simulink in two ways:

  • Click the Simulink icon on the MATLAB toolbar.
  • Enter the simulink command at the MATLAB prompt.

Starting Simulink

On Microsoft Windows platforms, starting Simulink displays the Simulink Library Browser as shown here.

To create a new model on Windows, click the New Model button on the Library Browser's toolbar.

Simulink opens a new model window as shown below:

  • 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 instructions for building this model in this section are brief.
  • The model integrates a sine wave and displays the result along with the sine wave. The block diagram of the model looks like this.

Model Example

Simulink Library

Sources Library

Sine Wave Block

Now drag a copy of the Sine Wave block from the browser and drop it in the model window.

Here is how the Library Browser should look after you have done all this.

To copy the Sine Wave block from the Sources library window, open the Sources window by double-clicking the Sources icon in the Simulink library window.

On Windows, you can open the Simulink library window by right-clicking the Simulink node in the Library Browser and then clicking the resulting Open Library button. Simulink displays the Sources library window as shown here.

Now it's time to connect the blocks. Connect the Sine Wave block to the top input port of the Mux block. Position the pointer over the output port on the right side of the Sine Wave block. Notice that the cursor shape changes to crosshairs

Connecting 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 crosshairs as it approaches the Mux block.

Now release the mouse button. The blocks are connected. You can also connect the line to the block by releasing the mouse button while the pointer is over the block. If you do, the line is connected to the input port closest to the cursor's position.

Drawing a branch line is slightly different from drawing the line you just drew. To weld a connection to an existing line, follow these steps:

First, position the pointer on the line between the Sine Wave and the Mux block.

Press and hold down the Ctrl key (or click the right mouse button). Press the mouse button, then drag the pointer to the Integrator block's input port or over the Integrator block itself Release the mouse button. Simulink draws a line between the starting point and the Integrator block's input port.