Professional Documents
Culture Documents
Matlab Overview
MATLAB is used in every facet of computational mathematics. Following are some commonly used
mathematical calculations where it is used most commonly −
MATLAB is widely used as a computational tool in science and engineering encompassing the fields of physics,
chemistry, math and all engineering streams. It is used in a range of applications including −
● Control Systems
● Test and Measurement
● Computational Finance
2
Matlab Interface
3
Basic Syntax
Basic arithmetic operations and variables
● ‘+’, ’-’, ’*’, ‘/’ can be used in matlab to perform basic operations.
for instance: input 5+5
ans=10
● variables can be declared to store data and can be retrieved later
from workspace.
example: ans,m,y
● exponentials , trigonometry functions can also be used.
3^2 ( ans=9 )
sin(pi/2) ( ans=1 )
4
● Semicolon (;) indicates end of statement. However, if you want to suppress
and hide the MATLAB output for an expression, add a semicolon after the
expression.
for example : x=3; y=x+5
input y
output 8
● The percent symbol (%) is used for indicating a comment line. For example,
● The save command is used for saving all the variables in the workspace, as a file
with .mat extension, in the current directory.
save myfile
5
6
Variables
You can assign variables in a simple way. For example,
x=3 %x assigns the value of 3
x=sqrt(16)
You can have multiple assignments on the same line.
a=2; b=7; c=a+b
● Once a variable is entered into the system, you can refer to it later.
● Variables must have values before they are used.
● When an expression returns a result that is not assigned to any variable, the system
assigns it to a variable named ans, which can be used later.
7
int8 8-bit signed integer
structure C-like structures, each structure having named fields capable of storing
8
Relational Operators
9
Conditional Statements
10