Lab Session 1
Lab Session 1
Lab Session 1
Introduction to MATLAB
OBJECTIVE:
INTRODUCTION:
MATLAB stands for matrix laboratory and it is a fourth-generation high level programming language. By
high level language we mean that the syntax of this language is easily understandable to human beings
and non-comprehensible to computers.
APPLICATIONS:
MATLAB is very efficient when it comes to manipulation of matrices, creating visualization of data and
other mathematical expressions in the form of plots, implementation of algorithms for the numerical
solution of complex problems pertaining to the field of engineering and sciences. Following are some of
the areas where MATLAB is used extensively:
MATLAB Environment
Current Folder
This shows the files present in the current working directory.
Command Window
In command window user can enter the statements one at a time or a set of statements by pressing
SHIFT+ENTER, after the set of statements is written and ENTER key is pressed, the output of those
statements or single statement is displayed in the command window.
Work Space
All the variables which are present in the memory are displayed in workspace.
Command History
This panel shows the commands which were executed in the command history, user can access the
command history by pressing the UP-ARROW key or by adding the command history panel in the layout.
Note that command history panel is not available in default MATLAB layout.
Getting Help
For getting help about any function the command help can be used along with the function name to
know about its syntax in MATLAB.
Output Format
There are different ways in which output can be displayed on the screen. The default output format is
short with loose spacing. There are different output formats according to the type of formatting
involved.
LAB SESSION 2
Simple Operations Related to Scalar, Vector and Matrices in MATLAB
Variable:
A variable in MATLAB is a name that is a combination of letter and numbers and numerical data can be
assigned to it. Variables can be an array or a matrix. Variables are used extensively to solve and
manipulate data. To define variables, there are some rules that must be following:
MATLAB is case sensitive, it means variable "x" and "X" are two different variables.
Assignment operator:
Variables can be assigned by using the assignment operator i.e =. It is used to assign numerical value or
results of an expression to a variable.
Constants:
A constant is something whose value does not change. It is usually a number. For example, in statement
k = 5, k is the variable and 5 is the constant.
COMMENTS:
• To describe the code when multiple persons are working on the same file.
Operators:
An operator is a symbol that tells the compiler to perform specific mathematical or logical
manipulations.
SCALAR QUANTITIES:
Scalar in MATLAB refers to a 1x1 matrix, that is a matrix with a single column is treated as a scalar. Scalar
operations include addition, subtraction, multiplication, division, exponentiation and nth root.
LAB SESSION 3
Operations related to vector and matrices in MATLAB