Vous êtes sur la page 1sur 5

Matlab Simulink Tutorial

Steps for simulating a resistive-inductive circuit in Matlab Simulink. 1. Start Matlab. 2. Click on the 'Command' window and type Simulink. The 'Simulink Browser Window' will appear. At this window, select File / New / Model from the menu. A blank window labeled 'untitled' will appear. 3. On the 'Simulink Library Browser' window, click Source and drag the Constant block to the blank workspace (the window labeled 'untitled'). In a similar manner, drag and drop the following blocks to the workspace from the respective menus: Menu User-Defined Functions Continuous Signal Routing Sources Math Operations Math Operations Block Fcn Integrator Mux Signal Generator Sum Gain

Arrange the blocks in the order shown here. The gain block can be flipped by clicking on it and selecting Format / Flip Block from the menu.

4. Add connecting wires by dragging the mouse from the output of one block to the input of another. Make all connections, so that the block diagram looks as shown below.

5. Modify the Sum block by double clicking on it and changing the second plus sign to a minus. Modify the Fcn block by double-clicking on it and replacing the expression with u(1)*u(2). This will be the product of the two inputs of the Mux.

6. Re-label the Gain blocks and change the values by double-clicking on them. You may have to stretch the gain blocks so that the value appears. For the Signal Generator block, set the Wave form to square and set the frequency to 60. Also re-label the Fcn block and label the wires by double-clicking on them.

7. Drag a Scope from the Sinks menu. Double-click on the Scope, click on the Parameters icon and set the Number of axes to 3. Also click on Data History and un-check the box titled Limit data points to the last: 5000. Stretch the Scope and connect it as shown.

8. Under the Simulation / Simulation Parameters menu, set the following: Stop time: 0.05 Type: Fixed-step ode5(Dormand-Prince) Fixed step size: 1e-4 9. Click on Simulation then Start

10. On the scope plot, right click on the gingival traces and select Axes properties. Set the range of the first trace from -2 to 2 and the range second and third traces from -0.2 to 0.2. The graph should look like this:

This tutorial has demonstrated the simulation of an R-L circuit. By inspecting the final block diagram it can be seen that the equation implemented is

v Ri L

di dt

where R 10 and L 10 mH . This can be seen by re-arranging the equation as

di 1 v R i dt L The traces on the scope are the voltage, current, and power of the R-L circuit. The inductive charging can be seen in the current waveform. It has a time constant of L/R which is 1 ms. Note that the power has a positive average value which as it turns out is equal to the rms value of the current waveform squared times the resistance.

This project has also demonstrated the use of Matlab Simulink. The use of the typical blocks such as Sum, Gain, and Integrator as well as other blocks such as Mux and Fcn has been shown.

Vous aimerez peut-être aussi