Sunteți pe pagina 1din 4

WINDOW

Command Window
Figure Window
Editor Window
Help window
Launch pad window
Command History Window
Workspace window
Current directory window

PURPOSE
Main Window, enters variables,runs programs
Contains output from graphic commands
Creates and debugs script and function files
Provides help information
Provides acces to tools , demos, and documentation
Logs commands entered in the command window
Provides information about variables that are used
Shows the files in the current directory

Command window:

Main window of matlab


Used for executing commands ,opening other windows and managing the
software
Command prompt is >>
After command enter is pressed to execute command
Several command can be typed in single line using comma between
commands , they are executed form left to right
Previously typed command can be recalled using key
Command too long can be extended to next line using three periods . And
pressing enter key
If semicolon used at the end of command output cant be displayed , typing a
semicolon is useful if result is obvious or output is large
% is used for comments
Clc command clears the command window

Arithmetic Operators:
Addition

Subtraction

Multiplication

Right division

Left division

Exponentiation

5/3=3/5

Order of Precendence:

First

Parenthesis,Innermost first

Second

Exponentiation

Third

Multiplication, Division

Fourth

Addition, subtraction

Elementary Math functions:

Function
Sqrt(x)

Description
Sqaure root

Exp(x)

exponential

Abs(x)

Absolute value

Log(x)

Natural logarithm

Log10(x)

Base 10 logarithm

Factorial(x)

Factorial function

Sin(x)

Sine of angle

Cos(x)

Cosine of angle

Tan(x)

Tangent of x

Example
>>sqrt(8)
Ans=
9
>>exp(5)
Ans=
1484132
>>abs(-24)
Ans=
24
>>log(1000)
Ans=
6.9078
>>log10(1000)
Ans=
3.0000
>>factorial(5)
Ans=
120
>>sin(pi/6)
Ans=
0.5000
>>Cos(pi/6)
Ans=
0.8660
>>tan(pi/6)

Cot(x)

Cotangent of angle

Round(x)

Round to nearest integer

Fix(x)

Round towards zero

Ceil(x)

Round towards infinity

Floor(x)

Round towards minus


infinity

Rem(x,y)

Returns the remainder


after x is divided by y

Sign(x)

Signum function returns 1


if x>0 , -1 if x<0 and 0 if
x=0

Assignment operator

Variable names

Predefined variables

.can be upto 63 charactes


long
.can contain letters ,
digits, and underscore
.must begin with a letter
.Matlab is case sensitive
.avoid using names of
built in functions for a
variable (sin,cos)
.ans

.pi

Ans=
0.557
>>cot(pi/6)
Ans=
1.7321
>>round(17/5)
Ans=
3
>>fix(13/5)
Ans=
3
>>ceil(11/5)
Ans=
3
>>floor(-9/4)
Ans=
-3
>>rem(13,5)
Ans=
3
>>sign(5)
Ans=
1
>>x=15
X=
15
>>x=3*x-12
X=
33
>>C=(a-B)+40-a/B*10
C=
18

Variable that has the valus


of the last expression that
was not assigned to a
specific variable

.eps
.inf
.i
.NaN
Clear
Who
Whos

Number
Smallest differnce
between two numbers
Used for infinity
Defined as underroot -1
Stands for not-a-number
Removes all variables
from memory
Display list of variables in
memory
Displays a list of variables
in the memory and their
sizes

S-ar putea să vă placă și