5
WINDOW PURPOSE Command Window Main Window, enters variables,runs programs Figure Window Contains output from graphic commands Editor Window Creates and debugs script and function files Help window Provides help information Launch pad window Provides acces to tools , demos, and documentation Command History Window Logs commands entered in the command window Workspace window Provides information about variables that are used Current directory window 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

Matlab Functions

Embed Size (px)

DESCRIPTION

General functions of matlab

Citation preview

WINDOWPURPOSE

Command WindowMain Window, enters variables,runs programs

Figure WindowContains output from graphic commands

Editor WindowCreates and debugs script and function files

Help windowProvides help information

Launch pad windowProvides acces to tools , demos, and documentation

Command History WindowLogs commands entered in the command window

Workspace windowProvides information about variables that are used

Current directory windowShows 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 \ 5/3=3/5Exponentiation ^Order of Precendence:

First Parenthesis,Innermost firstSecond ExponentiationThird Multiplication, DivisionFourth Addition, subtraction

Elementary Math functions:

FunctionDescriptionExample

Sqrt(x)Sqaure root>>sqrt(8)Ans=9

Exp(x)exponential>>exp(5)Ans=1484132

Abs(x)Absolute value>>abs(-24)Ans=24

Log(x)Natural logarithm>>log(1000)Ans=6.9078

Log10(x)Base 10 logarithm>>log10(1000)Ans=3.0000

Factorial(x)Factorial function>>factorial(5)Ans=120

Sin(x)Sine of angle>>sin(pi/6)Ans=0.5000

Cos(x)Cosine of angle>>Cos(pi/6)Ans=0.8660

Tan(x)Tangent of x>>tan(pi/6)Ans=0.557

Cot(x)Cotangent of angle>>cot(pi/6)Ans=1.7321

Round(x)Round to nearest integer>>round(17/5)Ans=3

Fix(x)Round towards zero>>fix(13/5)Ans=3

Ceil(x)Round towards infinity>>ceil(11/5)Ans=3

Floor(x)Round towards minus infinity>>floor(-9/4)Ans=-3

Rem(x,y)Returns the remainder after x is divided by y>>rem(13,5)Ans=3

Sign(x)Signum function returns 1 if x>0 , -1 if x>sign(5)Ans=1

Assignment operator>>x=15X=15>>x=3*x-12X=33>>C=(a-B)+40-a/B*10C=18

Variable names.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)

Predefined variables.ans

.pi.eps

.inf.i.NaNVariable that has the valus of the last expression that was not assigned to a specific variableNumber Smallest differnce between two numbersUsed for infinity Defined as underroot -1Stands for not-a-number

ClearRemoves all variables from memory

WhoDisplay list of variables in memory

WhosDisplays a list of variables in the memory and their sizes