advertisement

Get started with MATLAB/SIMULINK 1. Start MATLAB and SIMULINK (1) Access a computer lab or PC studio in Reber. (2) Start Matlab from the start menu or the desktop. (3) Change the directory using say “cd F:” at the >> prompt in the Matlab window. (4) To open Simulink library browser, type “simulink” at the >> prompt or click the “simulink” button in the toolbar. (5) Click “File” in the Simulink window and select “New” to create a new model or “Open” to reopen an existing model. 2. Build a SIMULINK Model and Run Simulation Chapter 6 and Appendix 4 in the textbook give detail procedures for developing and running Simulink models. (1) Translate a block-diagram model to a Simulink model. (2) Double-click say a “gain” block to define its parameter (either a symbol or a value). The values of all system parameters may be collectively defined in a Matlab m-file. Run it (to define/update parameters) before running the simulation. (3) Double-click an “integrator” block to define its initial condition. (4) Click “Simulation” to select simulation parameters such as integration algorithm, error tolerance and max time step etc. (5) Click “Simulation” or the “>” bottom to run the simulation. (6) Double click “Scope” block to see the results if such a block is used. 3. Output results (1) Output results using “To Workspace” block in the Sink category. Double click it to change its ‘Save format’ to ‘array’. (2) Type “whos” in the Matlab window to check variables generated. (3) To plot one curve, plot(x,y); To plot two curves, plot(x, y1, ‘-’, x, y2, ‘-.’). (4) To plot two curves in the same figure with different scales, plotyy(x,y1,x,y2). (5) To generate two subplots in one figure, use subplot(2,1,1), plot(x,y1), subplot(2,1,2), plot(x,y2) Type “help plot” for more information on plot Tutorial example for SIMULINK block diagram The state-variable equations for this system are x v v 1 ( Fi kx bv ) m The simulation block diagram for this system is The block diagram for SIMULINK 1 k 1 Step 1/m Scope 1 s 1 s x x_d x displacement 1 t b Clock time