Page 821 - Mechatronics with Experiments
P. 821

®
                                                               ®
                                                MATLAB , SIMULINK , STATEFLOW, AND AUTO-CODE GENERATION  807
                             it more convenient and easy to code the event driven nature of logic. Many examples are
                             provided under the
                                      ®
                             MATLAB > Help > Demos
                             menu with example categories in automotive, aerospace, and heating systems.
                                                              ®
                                                                       ®
                                  The main benefit of the MATLAB /Simulink environment over the standard high
                             level programming languages such as C/C++ are:
                                1. faster program development due to reduced detail in defining data structures (i.e.,
                                             ®
                                  in MATLAB , we do not have to declare data types before usage) and easy to use
                                  library functions (including I/O functions),
                                                                                      ®
                                2. good graphical communication of the model structure in Simulink and Stateflow as
                                  oppose to text based programming language description,
                                3. auto-code generation tools for real-time implementation.
                                                                ®
                                                       ®
                                  In addition, the MATLAB /Simulink environment can interface with external user
                             written C functions. However, use of external functions should be balanced with the diffi-
                                                                                   ®
                             culty they impose and maintaining the advantages of the MATLAB environment.
                                  MATLAB  ®  is started by double clicking on the MATLAB ®  short-cut icon on the
                             desktop under Windows development environment. The standard prompt of MATLAB ®
                             when it starts and opens its user interface window, called the “Command Window”,is
                             >>
                                                         ®
                             The user interacts with MATLAB from the command window. In addition, the window
                             has menu items which will allow the user to perform typical file I/O, print, and setup
                                                               ®
                             operations, and get help on any MATLAB topic.
                                              ®
                                  The MATLAB development environment has seven basic windows. Each window
                                                                          ®
                             is dockable and can be disconnected from the MATLAB window and treated as a separate
                             window. Each window can be opened/closed using the View menu check mark next to each
                                             ®
                             window. MATLAB ’s user interface is modified in each version a little bit. The current
                             version may have a slightly different user interface than described here.
                                  The main windows are (Figure A.2):
                                1. Command Window: the window through which the user enters MATLAB ®  com-
                                  mands interactively.
                                  >> clc ;     %   Clears the screen of the Command Window.

                                2. Command History Window: used to store and reuse previously used interactive
                                          ®
                                  MATLAB commands. It is useful during program debugging.
                                3. Workspace Window: this window shows all of the variables defined in the MATLAB ®
                                  workspace and their values.
                                  >> clear ;  % Clears (deletes) all data variables defined from the
                                                MATLAB® Workspace.
                                  >> who  ;   % Displays the currently defined data variables
                                              %  (without their size info) in the MATLAB® Workspace.
                                  >> whos  ;  % Displays the currently defined data variables
                                              %(with their size info) in the MATLAB® Workspace.
                                4. Current Directory Window: directory navigation window. Using the icons on this
                                  window, the user can quickly change the current directory. By default, MATLAB ®
   816   817   818   819   820   821   822   823   824   825   826