Introduction What is MATLAB The name MATLAB stands

Introduction

What is MATLAB? � The name MATLAB stands for matrix laboratory. � It is both a computer programming language, and a software environment.

variables § Variable name must begin with a letter. § MATLAB distinguishes between uppercase and lowercase characters, so A and a are not the same variable (case sensitive). § When naming a variable, make sure you are not using a name that is already used as a function name.

Special values function description Ans if you don`t assign an output variable to an expression, MATLAB automatically stores the result in ans. pi 3. 14159 inf Infinity. Calculations like n/0. Na. N I, J Not-a-Number, an invalid numeric value. Like 0/0 and inf/inf The imaginary unit √-1

Special values function beep description Beep sound. realmax Max real number that can be used. realmin Min real number that can be used.

operators § Arithmetic - numeric computations, e. g. , 2^10 § Relational - quantitative comparison of operand, e. g. , a > b § Logical , OR , NOT return Boolean variable, 1(true) and 0(false)

Arithmetic operators operation addition subtraction multiplication symbol example + * 3+22 division / or power ^ 54 -16 3. 14*6 100/10 10/100 5^2

Relational operators Description < <= > Less than or equal >= Greater than or equal == Equal to ~= Not equal to Greater than

logical operators Description & | ~ AND && Scalar AND with short circuiting || Scalar or with short circuiting OR NOT

Operator precedence operation 1 2 3 4 () ^ *, / +, -

Complex functions Item Description Define a complex number Complex(2, -3) or 23 I Real part of a complex number x Real(X) Imaginary part of a complex number x Imag(X) Absolute value ; |x| Abs(x) Angle of complex number x Angle(x) Conj(x) Complex conjugate of x

Example

System and file commands Item Description clc Clears command window Clear , clear all Remove variables from memory doc Display documentation exist Check for existence of files or a variables help Display help text helpwin Display help text in the help browser

System and file commands Item Description lookfor Searches help enters for akeyword quit or exit Stop MATLAB who List current variables whos List current variables(long display)

Trigonometric functions (Radian) Item Description Sin(x) , cos(X) , tan(x) Sine , cosine and tangent Sec(X) secant Csc(X) cosecant Cot(X) cotangent asin(X) Inverse sine acos(X) Inverse cosine atan(X) Inverse tangent acsc(X) Inverse cotangent

Trigonometric functions (Degree) Item Description Sind(x) , cosd(X) , tand(x) Sine , cosine and tangent Cscd(X) cosecant Cotd(X) cotangent asind(X) Inverse sine acosd(X) Inverse cosine atand(X) Inverse tangent acscd(X) Inverse cotangent

hyperbolic functions Item Description Sinh(x) , cosh(X) , tanh(x) Sine , cosine and tangent Csch(X) cosecant Coth(X) cotangent asinh(X) Inverse sine acosh(X) Inverse cosine atanh(X) Inverse tangent acsch(X) Inverse cotangent


System and file commands Item Description cd Change current directory mkdir to make anew directory pwd Present work directory dir List all files in the current directory what List all matlab files clock Display clock and date Display date


Example



Integration



Differentiation
- Slides: 27