One major 'gotcha' in Simulink is the sample time. See how to notice when it's being an issue and where to set the sample rate.
- [Instructor] One thing we need to look out for in Simulink is the sample rate of our simulation. As an example, let's go ahead and delete our white noise and our addition block and click on this arrow here, get rid of that too. And if I just drag my block over here, it'll connect itself automatically to our scope. I'm going to run the simulation, open up our scope. And we can already see there's some segmentation in our sine wave here, it's lookin' a little ugly. Let's turn the frequency up a little bit more. Frequency is two radians per second. Let's set it up to four.
Run our simulation again. Open our scope and we see it looks even worse. If we had a really high frequency, we might not be able to see our wave at all. We're going to get some really bad aliasing. There we go, our sine wave looks terrible and we can see it's starting to alias with this large envelope at the top. We can fix up this kind of behavior by increasing the sample rate of our simulation. Let's go ahead and open up our configuration parameters. Let's change the solver options from variable step to fixed step and then if we open up the additional parameters, we can see that we can adjust the fixed step size here.
Let's change this from auto to something much smaller, like .001. This'll increase the sample rate of our simulation but it could also make our simulation take a lot longer to run. Since we've just got a simple sine wave now, it shouldn't cause us any trouble. Let's go ahead and run the simulation. Open up our scope and we can see that our sine wave is much smoother as we've gotten many more data points. I encourage you to keep this kind of behavior in mind if your simulations ever start acting weird and you're not sure why, check out the sample rate as a first step.
- Creating MATLAB variables
- Working with matrix and scalar operations
- Using if statements and loops
- Creating functions
- Importing data
- Building basic plots and 3D plots
- Working with images
- Creating Simulink models