Wednesday, March 8, 2017

                                                                             Chapter-1
                                       Interacting with MATLAB
MATLAB can be used as a programming language and as a simulation software developed by mathworks.  Our tutorial gives you aggressively a gentle introduction of MATLAB programming language and simulink. It is assumed that the MATLAB software is installed on the computer and that the user can start the program. Once the program starts, the window that opens contains three smaller windows command window, workspace window and command history window. These are following windows in MATLAB:



COMMAND WINDOW – command window is MATLAB’s main window and opens when MATLAB is started. It enters variables and runs programs.
Fig 1.1: Example of command window

EDITOR WINDOW-The Editor window is used for writing MATLAB programs. This window is opened from the file menu in the command window. More details on editor window are given in chapter-3 where it is used to create a script file and in chapter-4 where it is used to create function file.
Fig 1.2 shows example of Editor window

WORKSPACE WINDOW-It provides information about the variables that are declared by user.
Fig 1.3: Example of workspace window


COMMAND HISTORY WINDOW-It contain list of commands that are entered in command window.
Fig 1.4: example of command history window

Current directory window or current folder- It shows list of files in current folder.
Fig 1.5: example of command history window

WORKING IN COMMAND WINDOW
·         command window can be used for executing commands, opening other windows, running programs written by the user.
·         To type a command in command window the cursor must be placed next to the command prompt (>>).
·         Once a command is typed and the Enter key is pressed, the command will get executed.
·         Any output that the command generates is displayed in the command window. If a semicolon (;) is typed at the end of the command the output of the command is not displayed.
ARITHMETIC OPERATIONS WITH SCALARS


EXAMPLE OF USING MATLAB AS A CALCULATOR



LIST OF COMMONLY USED MATLAB MATHEMATICAL BUILT-IN FUNCTIONS


TRIGONOMETRIC MATH FUNCTION


·         Similarly  pre-defined inverse trigonometric functions are asin(x), acos(x), atan(x), acot(x).
·         Hyperbolic trigonometric functions are sinh(x), cosh(x), tanh(x), coth(x).

ROUNDING FUNCTIONS


PREDEFINED VARIABLE

Pi – The number pi

eps – The smallest difference between two numbers equal to 2^(-52) = 2.2204e-16

inf – used for infinity

NaN – stands for not a number

Other useful commands in MATLAB

clear all – removes all variables from the memory

clc – command clears the command window.

clear x y z – removes variables only x, y and z from memory

who – display a list of variables currently in memory

whos – display  a list of variables currently in their memory and their size








No comments:

Post a Comment