MATLAB Simulink – Quick Guide

MATLAB Simulink – Quick Guide ”; Previous Next MATLAB Simulink – Introduction Simulink is a simulation and model-based design environment for dynamic and embedded systems, which are integrated with MATLAB. Simulink was developed by a computer software company MathWorks. It is a data flow graphical programming language tool for modelling, simulating and analysing multi-domain dynamic systems. It is basically a graphical block diagramming tool with a customisable set of block libraries. Furthermore, it allows you to incorporate MATLAB algorithms into models as well as export the simulation results into MATLAB for further analysis. Simulink supports the following − System-level design. Simulation. Automatic code generation. Testing and verification of embedded systems. To get started with Simulink, type simulink in the command window as shown below − It will open the Simulink page as shown below − You can also make use of Simulink icon present in MATLAB to get started with Simulink − When you start Simulink, you are navigated to the start page as shown below Here you can create your own model, and also make use of the existing templates. Click on the Blank Model and you will get a Simulink library browser that can be used to create your own model. The screen for Blank model is as follows − Click on Library and it will display you the Simulink library as shown below − The Simulink library browsers is a collection of many libraries. It offers Commonly Used Blocks, Continuous, Dashboard, Logic and Bit Operation, Math Operations etc. Besides that, you will get other library list like Control system toolbox, DSP system toolbox etc. Here is an example of Math operations library list − It has Abs, Add, Algebraic Constraint, Assignment etc. that you can make use in your model. Given below is an example of Logic and Bit Operations − MATLAB Simulink – Environment Setup MATLAB simulink is a MATLAB product and to work with it, we need to download MATLAB. The official website of matlab is https://www.mathworks.com/ The following page will appear on your screen − To download MATLAB go to https://in.mathworks.com/downloads/ as shown below. MATLAB is not free to download and you need to pay for the licensed copy. Later on you can download it. A free trial version is available for which you have to create a login for your respective account. Once an account is created, they allow you to download MATLAB and also an online version for a trial of 30 days’ license. Once you are done with the creating a login from their website, download MATLAB and install on your system. Then, start MATLAB or you can also make use of their online version. Simulink comes in-built with MATLAB. Once you install MATLAB, you will get Simulink as shown below − MATLAB Simulink – Starting Simulink In this chapter, we will understand about using Simulink to build models. Here is a MATLAB display − You can start Simulink by using simulink command in the MATLAB command window as shown below − Click on enter to open the Simulink startup page as shown below − You can also open Simulink from MATLAB interface directly by clicking on Simulink icon as shown below − When you click on the Simulink icon, it will take you to a Simulink startup page, as shown below − The startup page has a blank model, subsystem, library to start the model from scratch. There are also some built-in templates that can help the users to start with. To create a model, the user can click on blank model and it will display a page as shown below − Click on Save to save your model. The blocks to build your model are available inside the Simulink library browser. Click on library browser as shown below − The library browser has a list of all types of libraries with different blocks as shown below − Libraries in Simulink Let us understand some of the commonly used libraries in Simulink. Continuous A continuous blocks library gives you blocks related to derivatives and integrations. The list of blocks are as follows − Dashboard With Dashboard, you will get controls and indicator blocks that help to interact with simulations. The following screen will appear on your computer − Discontinuities Here, you will get a list of discontinuous functions blocks as displayed below − Discrete Here, you will get time relation function blocks as shown below − Logic and Bit Operations In this category, you will get all logical and relational type blocks as displayed below − Lookup Tables You will all the sine, cosine function blocks as shown below − Math Operations All mathematical operations like Add, Absolute, divide, subtract are available. The list is as follows − Messages and Events This block has all the message/communication related functions as shown below − Model Verification The blocks present here helps to self-verify models, such as Check Input Resolution. The following screen will appear on your computer − Model-Wide Utilities This gives you blocks like Model info, Block Support Table etc. The following screen will appear on your computer − Ports and Subsystems You will get blocks like a subsystem, switch case, enable etc. The list is displayed below − Signal Attributes Modify the signal attribute blocks such as Data Type Conversion. The following screen will appear on your computer −

Solving Mathematical Equation

Solving Mathematical Equation ”; Previous Next In this chapter, we will solve a simple mathematical equation by using Simulink. The equation is given below − y(t) = 2Sin(t) + 5Sin(2t) – 10 Let us create a model for the above equation. Open a blank model as shown below − Following are the steps to solve the equation − Get a Sine wave block. Right click and select block parameters. Select sign type as time based. Change the amplitude to 2 and frequency to 1. That will be 2Sin(t). Get another sine wave block. Now, set the amplitude to 5 and frequency to 2 to display 5Sin(2t). Select sign type as time based. Now get an add block and add both sine waves. Get a constant. Right click and select block parameters. Change the value from 1 to 10. Get a subtract block where one input will come from step 3 and another from constant i.e. step 4. Get a scope block and connect the input from step 6 to it. This is how the final Simulink model looks like for the equation − y(t) = 2Sin(t) + 5Sin(2t) – 10 Click on the run button to compile. Right Click on scope block to see the signal plotted. Print Page Previous Next Advertisements ”;

MATLAB Simulink – Sinewave

MATLAB Simulink – Sine Wave ”; Previous Next In this chapter we will integrate and differentiate sine wave by using the derivative and integrator blocks. Open blank model and Simulink library as shown below − Let us pick the sine wave from sources library and scope block from sinks library. We would like to add the derivative and integrator block from continuous library as shown below − We would need 3 input ports for scope block as the sine wave, derivative and integrator block will be connected to it. Right click on the scope block and change the inputs from 1 to 3 as shown below − Connect the lines as shown below − Now, run the model to see the display. So, we have three signals sine wave, derivative and integrator. Print Page Previous Next Advertisements ”;

MATLAB Simulink – Discussion

Discuss MATLAB Simulink ”; Previous Next MATLAB (Matrix Laboratory) is a programming language developed by a computer software company MathWorks. Simulink is a simulation and model-based design environment for dynamic and embedded systems, which are integrated with MATLAB. Simulink is also developed by MathWorks. This tutorial is designed to give students fluency in MATLAB Simulink. Problem-based examples have also been given in simple and easy way to make your learning fast and effective. Print Page Previous Next Advertisements ”;

First Order Differential Equation

First Order Differential Equation ”; Previous Next Here, we will learn how to solve the first order differential equation in Simulink. The first order differential equation that we are trying to solve using Simulink is as follows − dy/dt = 4sin2t – 10y The equation can be solved by integrating dy/dt to the following − y(t)=∫(4sin2t – 10y(t))dt Following are the steps to build a model for above equation. Pick up sine wave from sources library and change the amplitude to 4 and frequency to 2. This will give us 4sin2t. The integrator block will be used to show dy/dt that will give output y(t). The gain block will represent 10y. The input of step 1 and 3 will be given to step2. We need scope block to see the output y(t). The step 4 will be connected to the scope block. Let us see the above steps in model as shown below − Run the block to see the following output − Print Page Previous Next Advertisements ”;

MATLAB Simulink – Create Subsystem

MATLAB Simulink – Create Subsystem ”; Previous Next Subsystems are useful when your model gets big and complex. You can change a part of the model into a subsystem that helps to keep the flow very clean and understandable. In this chapter, let us learn how to create a simple subsystem in Simulink. First, create a blank model, as shown below − Now, we will create a simple model that adds two numbers and later converts a part of the model into a subsystem. We have created a simple model that has two inputs. These inputs will add up and show the result inside the display. We will change the value of the constant as 10 and 20. The result 10+20 = 30 should be seen inside the display block. Let us add one more block named Unary minus that will change the output from 30 to -30 as shown below − Now, let us select the portion i.e. the sum and the Unary minus block to create a subsystem as shown below − Click on Create Subsystem. Once done, the sum block and the Unary minus block will be converted into a subsystem as shown below − Now when you run the simulation, it will display the same result as earlier Double click on the subsystem to see the original block as shown below − Click on the upward arrow close to the subsystem to get back to the model. Print Page Previous Next Advertisements ”;

MATLAB Simulink – Useful Resources

MATLAB Simulink – Useful Resources ”; Previous Next MATLAB (Matrix Laboratory) is a programming language developed by a computer software company MathWorks. Simulink is a simulation and model-based design environment for dynamic and embedded systems, which are integrated with MATLAB. Simulink is also developed by MathWorks. This tutorial is designed to give students fluency in MATLAB Simulink. Problem-based examples have also been given in simple and easy way to make your learning fast and effective. Useful Links on MATLAB Simulink MATLAB Simulink Wiki − Wikipedia Reference for MATLAB Simulink. MATLAB Simulink − Official website of MATLAB Simulink. Useful Books on MATLAB Simulink To enlist your site on this page, please drop an email to [email protected] Print Page Previous Next Advertisements ”;

MATLAB Simulink – For Loop

MATLAB Simulink – For Loop ”; Previous Next In this chapter, let us understand the working of for-iterator block. First, create a blank model as shown below − In this model, we are going to make use of for iterator that will give us the sum of 1..N. You can use the value of n as per your choice. This value will take the constant block and update it with value 5 as shown below − Let us add the for-iterator block as shown below − Select the for Iterator subsystem block and add to your model. Next, we need display block as shown below − Connect the blocks as shown below − The for iterator block is a subsystem. Select the block and click enter. It will take you to new model area, where the for block has to be defined. Right click on the for iterator and select the block parameters, as shown below − Change the States when starting as reset and Iteration limit source as external. Click on Ok to update the changes. Now, you will get an input block to your for loop, as given below − We need a sum block and a delay block as shown below − The delay block has to be flipped so that it can be added to the output. We need to give the output back to the sum block so that it can be added with the current iteration. Right click on delay block and change the delay length from 2 to 1 as shown below. Click on OK to update the changes. The final for-loop subsystem block will look as follows − Now before you run the simulation, change the stop time to 1. We do this because we want the simulation to run only once. Click on Run now to see the result in display block as shown below The input value is 5, so the for-loop will go from 1 to 5. Hence, the values 1+2+3+4+5 = 15 is shown in the display. Print Page Previous Next Advertisements ”;

MATLAB Simulink – Build & Simulate Model

MATLAB Simulink – Build & Simulate Model ”; Previous Next We have seen the Simulink library browser and the blocks available in the library list. In this chapter, we are going to use the blocks to build a simple sine wave model. Open Simulink and click on blank model as shown below − The blank model will open a blank popup window as shown below − Now, open the Simulink Library browser so that we can select the blocks. The following screen will appear on your computer To move the sine wave to your model, select the block and drag it inside your model workspace. We want to display the sine wave and here, we have taken four sign wave in our model workspace as shown below − Now we want to display the output of the signal, so let us use a Scope block from sinks library as shown below − Now select and drag the Scope block inside your model workspace. The sine wave has one output and the scope block has one input. We have four sine waves displayed. We have to change the parameters of scope block to take four inputs. Right click on scope block and click on Block Parameters and it will display the screen as shown below − Go to settings icon and change the input parameter from 1 to 4 as shown below − Click on Apply to save the changes. Let us now connect the sine wave to the scope block with arrows as shown below − We would like to change the frequency of each sine wave to a different one, so that we get a signal graph of different frequencies. So right click on sine wave and open the Sine wave block parameters as shown below − We are going to keep the amplitude as 1 for all sine waves and the frequency of the first sine wave is 1, second one is 3, third one is 6 and the last one is 10. Click on the Run button as shown below to see the sine wave. Open the scope block parameters to see the sine wave as shown below. Print Page Previous Next Advertisements ”;

MATLAB Simulink – Mathematical Library

MATLAB Simulink – Mathematical Library ”; Previous Next In this chapter, we will learn how to sum the two given signals and get the output. Select the blank model and open Simulink library browser as shown below − We are going to combine chirp signal and sine wave blocks by using add block from Mathoperation and see the final display. Let us pick the block we want. Select chirp signal and sine wave from sources library, add block from math operations, scope block from sinks library. Join the lines to each block. Double click chirp signal and change the initial frequency from 0.1 to 0.05 and click on Ok button. The other blocks are kept as the default values. Now, click on run to see the output in scope as shown below. Print Page Previous Next Advertisements ”;