From the series: Getting Started with Simulink
Michael Carone, MathWorks
Priyanka Gotika, MathWorks
Learn how to get started with Simulink®. Explore the Simulink start page and learn how to use several of the basic blocks and modeling components. The example shows how to build a simple model that takes a sine wave input and amplifies it. It outlines how Simulink makes it easy to drag and drop blocks into your model. It also shows how to run your simulation to verify that your model behaves as expected.
Hello and welcome to the webinar, Simulink for new users. My name is Priyanka, I'm the product marketing manager for Simulink.
And hi, I'm Michael, Senior Product Marketing Manager, also for Simulink.
And today we are going to talk about how you can get started with Simulink. We'll use these four blocks here-- modeling, simulation, essentially three blocks, and collaboration. And we will show you how to use some of the features, get started with Simulink, get running with building models.
Right. So I think we want to present this in terms of, how would you use Simulink. Typically you would start building out a model, designing a system, and then simulating the model to make sure that that system is behaving the way you expect it to behave. And then once you are happy with the results, and you want to share your model with others-- either in your team or across organization-- what's the best way to do that. So we're kind of going to go over all those different things.
Yeah. So without further delay, we can get started with, you know, showing you how you can do these things within MATLAB. So let me bring up MATLAB here. And anyone who's used MATLAB, this is how the interface would look like. We have this common window where you can start typing commands. And to get started with Simulink, first I'll start typing Simulink in here. And if I hit Enter, it opens up a Simulink start page. Let's maximize it. What we have here are a few templates that allow new users to get started with. For example, we have a digital filter, or feedback controller with some of the blocks already existing, so you don't have to open a blank Simulink model.
And if you have other products besides Simulink, as you scroll down, there's different starting point templates for the other products as well. But I think for our presentation today, we're just going to start with the blank model, right?
Yeah, just to show how easy it is to set up a model, I would like to start with a blank model. And this is how a blank submitted canvas would look like. As a first step, I would just want to save my model. So I just followed My Model and save it in the same current directory as I'm working.
Sounds good. So we have a blank model. And we need to put some blocks inside of here, and so the best way to do that-- probably the library browser, right?
Yes. So Simulink is a block diagram environment. All you want to do is to bring some blocks. And the blocks can be accessed from this Simulink library browser. I just clicked the library browser from the menu here. And that brings up this library browser, which has-- not only Simulink but all other products and several blocks that you can simply drag and drop. So you don't have to build some of these blocks on your own, but you can use some of the pre-existing blocks.
So what type of model do you think we should build just as a starting point sample model?
Yeah, so for the first example, let's build a very simple model, which takes in a sine wave input, amplifies it by a factor, and a way to just work with signals. So for that I'll use the sources library, which has different blocks that act as a signal source. As you can see, you can have a constant value as a signal source.
But you're looking for a sine wave.
Sine wave, yeah. So I'll just bring in the sine wave block. I'll just drag it and drop it. And that will bring a block into my model. And when I did that, it gave me an option of what my amplitude should be for the sine wave. I can simply ignore it and go with the default value, which is 1, or I can give another value here.
Now let's bring other blocks that allow amplification of this wave. One of the nice ways you can bring in blocks is through quick insert, where you can just click on the canvas for one time. It will bring up a search magnifying glass. And you can start typing the names of the blocks if you already know what to use.
OK, so you know let's say we want to add a gain block into the model.
Usually we know that gain is what is used to multiply a particular value by a factor. So I'll type that in. And that showed me all the search results from various different libraries that are available. Again, just looking and mapping back to the library browser.
So it tells you everything with the word gain-- every block that has the word gain in it. And to know which one to choose, you can see, underneath each name tells you the name of the product where that block exists, and then the sub library for the--
So I'll just use the math operations library and bring that gain block in. Say you want to multiply it by a factor of 3, I can just enter 3 here, similar to what you did for the sine wave. But if you miss that, or just went for the default value, you can always doubleclick and change the value here. As you go through your modeling exercise, you might want to try several values as it works for you. So you can do that.
So that little prompt that shows up, that's really just a convenience.
So you don't have to open up this dialogue box if you don't want to.
Yeah, when you-- when you quickly want to build something, you can use the convenience mechanism that comes in with the quick insert but otherwise, you can just use the block dialogues. So-- and then once you have a couple blocks here, connecting these two is very simple. Drag a signal and adjoin it to the next block next to it.
And now that we have an input and we have amplified it by a value, we want to visualize it. Theoretically, we know that it should multiply that signal by 3. So for visualizing--
I'll do it with a scope.
Yeah, scope is the most popular way in which you can visualize signals within Simulink. So I just searched for it. It's in sinks library, and I'm adding it back to the model. Now I'll add two ports for this, because I want to visualize the output signal, which is this. And you do see this nice guide that lets you connect these signals whenever--
Yeah, anytime you align two blocks you're going to get basically an alignment indicator to help you create a nice clean looking diagram.
And the good thing is you don't-- I didn't have to drag the signal. It just-- clicking it would connect it, connect the block. Now to connect this block, I just simply drag that signal and add it to the scope block.
Now that time, you didn't do your basic left click drag. You did a right click drag for that, right?
Yes. If I did a left click, that would just move the signal around. But if I do a right click, that will branch out the signal. And once you have a branch, you can simply drag it with the left click. So I'll just select the branch and delete it for now.
And then I can use some of the keyboard shortcuts like spacebar to fit the whole model to view or use zoom and pan, using the mouse wheel, that allows you to look at your model.
We want to maximize our space, right?
So we're ready to simulate, right?
Yeah. I'll close up the library browser, open up our scope block, so we can see our simulation results. And simply run the simulation. Once I run it, you see the input, which is a sine wave with amplitude of 2. It's amplified by a factor of 3. You see the output here.
All right, that's good. So you run the simulation just to make sure that everything is behaving the way we expect it to behave. It is, so we're pretty happy. So this is a pretty common workflow, right?
You build up your model. Anytime you're making changes, you want to press play as often as possible so that it basically keeps you honest. And you're always verifying to make sure that the building can be simulated.
Yes. And that's kind of the power of Simulink. To be honest, if I just went here and changed the value, simply press the Play button and quickly visualize it in the scope block. So that's what you would want to do it Simulink.
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .Select web site
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.