MATLAB Environment Programming

Objective: To study MATLAB environment and to familiarize with command window, history, workspace, current directory, figure window, edit window, shortcuts, helplines.

MATLAB is a particular computer program optimized to perform engineering and scientific calculations.

Advantages:

  • Ease of use.
  • Platform independence.
  • Predefined functions.
  • Device-independent plotting.
  • GUI.
  • MATLAB compiler.

Disadvantages:

  • Interpreted language.
  • The cost is high.
  • MATLAB Programming Environment

    MATLAB Environment

    • Command Window: It is the space where commands may be entered.
    MATLAB Programming Environment
    • Figure Window: It displays plots and graphs.
    • Edit Window: It permits a user to create and modify MATLAB programs by creating new M files or to modify existing ones.
    • Current Directory Window: It shows the path of the current directory.
    MATLAB Programming Environment
    • Command History: It displays a list of commands that the user has entered in the command window.
    MATLAB Programming Environment
    • Workspace: It is a collection of all the variables and array that can be used by MATLAB when a particular command, M file, or function is executed.
    MATLAB Programming Environment
    • Help Files: A user can get help from MATLAB through MATLAB documentation.
    MATLAB Programming Environment

    Shortcuts of MATLAB:

    In MATLAB, if the statement is too long to type on a single line, it may be continued on successive lines by typing an ellipsis (...) at the end of the first line and then continuing on the next line.

    Ex: a=1/2+3/2-2/3 ...
               +4/5-2/3;

    Shortcuts:

    • clc: clear command window.
    MATLAB Programming Environment
    • clf: clear contents of the current figure window.
    • clear: clears variables in workspace
    • abort: (ctrl+C) For M files that appears running too long may contain an infinite loop that never terminates. To terminate, we use abort.
    • !: It is a special character, after which any character or command will be sent to the operating system and executed as they had been types in operating system command prompt.
    • diary: (diary filename)
      After this command, a copy of all inputs and most of the outputs typed in the command window will be echoed in the diary file.
    • diary off: It suspends input into the diary file.
    • diary on: It resumes input again.
    • which: It tells which version of a file is being executed and where it is located.

    Note

    • Never use a variable with the same name as MATLAB function or command.
    • Never create an M file with the same name as MATLAB function or command.





    Latest Courses