[MUSIC] Okay, so now once you have downloaded the software, and I have download that in my Downloads folder, then the first thing you want to do is to unzip that. So I go to my Downloads folder and then double click there, and this will create the folder that includes the software. And, what I suggest is that you look at the Read Me file to understand how to install this. So, the first thing that you notice here is that if you have a previous version of this toolbox, then you might want to go through the uninstall procedure. It's very simple, you just run a command called TBClean. Then you check where you have your minimum system requirements, and the minimum here is R13. And my computer, we have updated to R14, and you might have a newer version, and this software runs in newer versions as well. And to install it basically you need to save the file and then put it in a location that you can find it then open MATLAB. So we're going to do that. So we have R2014b. Basically this is going to, if this loads, basically this is going to generate a number of files that you can access. You can actually modify them, so this is totally open source. But it will include a number of examples that will help you to understand how to simulate CPS. All right, so once this opens up, what you need to do is you need to go to the Downloads location. So I will go to this location right there. So, that's the script and we need to execute in order to install the software. So, let me do that. The first thing that it's going to ask me is whether I would like to add the toolbox permanently into my startup path and I recommend that to say yes to that. That's the default option. Now it's going to install all these files. Look, they're installing them mostly in your Documents folder so that you can actually find them. You may want to delete installation files so that you don't reinstall it without uninstalling it. And then once installation is finished this system is ready to use. One of the features that toolbox has is that it integrates seamlessly with, not only the work space, but also with simulating, so that's what's happening right now. But if we go back to our location where our files are, then we can go back to our Documents. And now in MATLAB we will have that folder HyEQ_Toolbox_V2_04 where you will find basically all of the files. In addition in the Download location once you install that, the installation file has disappeared. But the PDF with all of instructions associated to the toolbox is here and it has a number of details in more than 70 pages that you might find interesting and important in how we actually coded it this way. Most of this is also in the help files in the model installation. So once you finish this installation which is still, which is taking a little bit of time to update on that. Then you can actually see that some of these things have passed without any problem. There is an error there that might be because of the version, but I will debug that later. And there are some changes and you may need to do locally. But those are suggested in the document that I mentioned to you already with instructions. So but the first thing that you can do is actually see whether this works. So I will go back to my Home folder and then to My Documents and then to MATLAB, and then to that folder. And there is a subfolder called examples, where you will see a number of examples. So the number of examples here that are listed in this folder are matching with the number of examples given in the PDF that I mentioned earlier. And one of the simplest hybrid system is a ball that falls and eventually hits the ground where it generates a rebound. And then the ball moves in the vertical up and then this behavior keeps repeating over and over until all of the energy of the ball is dissipated and the ball becomes at rest. So that type of hybrid system is modeled in these first example, Example 1.2. So I'm going to do is to get into that example and then run that example to make sure that everything has run. So this is a script command that runs what we call the light simulator, it's a simulator that does not require Simulink. And this is the result of it, so let's take a look at the trajectory that we obtained. As you see here, this is a plot position of the ball verses time. And this is velocity of the ball versus the time. So, for a rather large step size, what you see is that the ball starts to fall from height equal to one, hits the ground, at which time the velocity is negative, that corresponds to the ball moving towards the ground. After the impact the velocity gets changed sign, and it's magnitude is decreased by some factor which is adjusted by the restitution factor from where it goes up and then hits the ground again. So the velocity is positive, eventually becomes zero, at this apex time. And then it becomes negative until it reaches the ground. And then this behavior continues evolving over and over. Similarly, we can only simulate up to a certain amount of flow time and jump time, as you know. And the trajectory that you take from the simulator stops after making a finite many of those. And as you see the energy tends to zero as the position tends to zero and the velocity tends to zero. So it's a sanity check that this is working. The plot that you saw here is a plot that actually generates the hybrid arc that defines the solutions to our CPS as well. And as you see here, at every impact j is being incremented as t grows and the hybrid time domain that you obtain is a hybrid time domain that is of the form of a sceneo hybrid time domain. And this is due to the fact that the time of flow after each impact gets smaller and smaller because the restitution coefficient is small. Actually you can take a peek about what those numbers are, so for instance that would be the GEM map. So if you double click on this function the GEM map, it actually is the case that the restitution coefficient is 0.8 and therefore the energy decreases every time that impact occurs. So this is validated that we have the simulator working. The next thing will be to go and validate that the Simulink portion of this has been also installed properly. So, let's type Simulink. So if you are familiar with Simulink, it's a graphical user interface that will allow you to simulate system using modular functions and mock up blocks that actually can be interconnected to build a somewhat complex system that you'd like to simulate. Now one of the things that we did was to integrate the Hybrid Equation Toolbox within Simulink. So now you can click here and you can see that there are three sub types in here that can be used to simulate hybrid systems. And for this course the interest is in the first one, the one that corresponds to cyber physical systems. As you see right here, we have a block that is already configured. All we need to do is to change the constant that defines how often the conversion from analogue to digital occurs for this analogue to digital converter. We have also a digital to analog converter, or zero order hold block. We also have a finite state machine block, we also have a physical system block, which is essentially a differential equation, potentially with constraints, and also a network. So the idea is that with these blocks now, we will be able to build our CPS. We will be able to interconnect converters with physics, with algorithms, and with networks and simulate them in a similar that you simulate any type of mechanical system, and validate some of our analysis. [MUSIC]