Tuesday, July 16, 2019

[ MATLAB Tutorial - Lession 26] Matlab Simulink

Simulink is a simulation and model-based design environment for dynamic and embedded systems, integrated with MATLAB. Simulink, also developed by MathWorks, is a data flow graphical programming language tool for modelling, simulating and analyzing multi-domain dynamic systems. It is basically a graphical block diagramming tool with customizable set of block libraries.
It allows you to incorporate MATLAB algorithms into models as well as export the simulation results into MATLAB for further analysis.
Simulink supports −
  • system-level design
  • simulation
  • automatic code generation
  • testing and verification of embedded systems
There are several other add-on products provided by MathWorks and third-party hardware and software products that are available for use with Simulink.
The following list gives brief description of some of them −
  • Stateflow allows developing state machines and flow charts.
  • Simulink Coder allows the generation of C source code for real-time implementation of systems automatically.
  • xPC Target together with x86-based real-time systems provide an environment to simulate and test Simulink and Stateflow models in real-time on the physical system.
  • Embedded Coder supports specific embedded targets.
  • HDL Coder allows to automatically generate synthesizable VHDL and Verilog.
  • SimEvents provides a library of graphical building blocks for modelling queuing systems.
Simulink is capable of systematic verification and validation of models through modelling style checking, requirements traceability and model coverage analysis.
Simulink Design Verifier allows you to identify design errors and to generate test case scenarios for model checking.

Using Simulink

To open Simulink, type in the MATLAB work space −
simulink
Simulink opens with the Library Browser. The Library Browser is used for building simulation models.
 Simulink Library Browser
On the left side window pane, you will find several libraries categorized on the basis of various systems, clicking on each one will display the design blocks on the right window pane.

Building Models

To create a new model, click the New button on the Library Browser's toolbar. This opens a new untitled model window.
Simulink New Model Window
A Simulink model is a block diagram.
Model elements are added by selecting the appropriate elements from the Library Browser and dragging them into the Model window.
Alternately, you can copy the model elements and paste them into the model window.

Examples

Drag and drop items from the Simulink library to make your project.
For the purpose of this example, two blocks will be used for the simulation - A Source (a signal) and a Sink (a scope). A signal generator (the source) generates an analog signal, which will then be graphically visualized by the scope(the sink).
Source and Sink
Begin by dragging the required blocks from the library to the project window. Then, connect the blocks together which can be done by dragging connectors from connection points on one block to those of another.
Let us drag a 'Sine Wave' block into the model.
Sine Wave Block
Select 'Sinks' from the library and drag a 'Scope' block into the model.
Scope Block
Drag a signal line from the output of the Sine Wave block to the input of the Scope block.
Blocks are not connected
Blocks are connected
Run the simulation by pressing the 'Run' button, keeping all parameters default (you can change them from the Simulation menu)
You should get the below graph from the scope.
Simulation

No comments:

Post a Comment

Back to Top