Introduction to Using Simulink in MatLab

by efrisch112 in Circuits > Software

5389 Views, 24 Favorites, 0 Comments

Introduction to Using Simulink in MatLab

download (1).jpg
MatLab is a useful tool for writing programs to carry out higher order functions and matrices. Sometime though, sifting through, or writing lines of code can  be overwhelming and tedious. There is a part of MatLab however where you can create a code by using symbols instead of letters and numbers. this part of MatLab is called Simulink. it can make writing certain types of code much faster and easier. it can also be an easier way to code a problem if the user has a limited knowledge of writing codes. This set of instructions will go over the very basics of using Simulink.

Materials/Background Knowledge

download.jpg
Materials required:

A computer
Access to MatLab 

Time Required:

20-30 minutes

Background:

It is not required, but having some knowledge of code writing will be useful.

Open Up MatLab

matlab icon.png
matlab main.png
First you are going to want to open the MatLab program. The Icon can be seen in the first picture.
The second picture shows the main MatLab page when the program is open.

Open Simulink

simulink icon.png
simulink library.png
Next you are going to want to look at the top tool bar, you will see a box with four smaller boxes inside with the word Simulink Library under it. Click  on this, it can be seen in the picture.

Have some patients, loading the library can take some time, no more then a couple minutes though.

the second picture shows the Library of all the symbols that can be used to write code using Simulink.

Simulink Library

common blocks.png
The Next step is to go over to the left set of folders and go down and click on the set called commonly used Blocks.
you will see a set of Blocks as in the picture. these are the most common Blocks that are used when writing simple codes in Simulink. Some are self explanatory, others require more in depth descriptions that I wont go into here.

Creating a New Code

new code.png
Select any block, in this case I selected the constant Block, right click and select add to new model. this will open a new screen like the one shown in the second picture. The Block you selected will be there. This window is the window where your code will be constructed. From now on, to add new Blocks, they just have to be clicked and dragged into this window.

Basic Math Functions

math terms.png
To add new Blocks, they just have to be clicked and dragged into this window. So far in this model I have three Blocks, the constant Block, the addition Block and the gain Block. the constant block is basically just a number, the addition Block allows you to add, or subtract, two or more other Blocks together. the gain Block is like a multiplier.

Block Parameters

block parameters.png
To change the properties of the Blocks, double click on the block and a window like the picture will pop up. This is the properties for the constant Block, here you can change the value of the constant from 1 to say, 5.

Making Formulas

connecting with arrows.png
To  connect the Blocks together like in the picture, simply click on the arrows and drag them to the other Block you want to connect it to.

Making a Loop

making a loop.png
Using the arrows, you can also  make a Loop, if you want to take the end product of your equation and feed it back into the beginning. This is essential for solving differential equations. As can be seen by the use of the integrator Block in the picture.  

Using Scope Block

sine code.png
scope view.png
The scope Block can be used to view a graph of your results, say your using a differential equation like in the previous case or something as simple as the sine function as shown in the picture. simple add the scope Block and drag the arrow to whatever part you want to visualize. Then run your program, and double click on the scope Block and a new window will pop open like the one in the second picture.

Video

Here is a video showing how to open MatLab and then open up Simulink and change the properties of a block.

Conclusion

Now you have a basic understanding of what Simulink can do. The best way to get better is to play around with it and explore the different kinds of Blocks there are and experiment with the different types of codes and equations that you can come up with.