Presentation is loading. Please wait.

Presentation is loading. Please wait.

BASICS OF MATLAB Engr.Mian Shahzad Iqbal Lecturer,Telecom Department University of Engineering & Technology Taxila.

Similar presentations


Presentation on theme: "BASICS OF MATLAB Engr.Mian Shahzad Iqbal Lecturer,Telecom Department University of Engineering & Technology Taxila."— Presentation transcript:

1 BASICS OF MATLAB Engr.Mian Shahzad Iqbal Lecturer,Telecom Department University of Engineering & Technology Taxila

2 In this presentation … You will identify the different windows in the MATLAB desktop. You will learn some of the basics of programming in the MATLAB. You will learn to use MATLAB as an interactive calculator.

3 MATLAB interactive session

4

5 VARIABLES

6 A Variable in MATLAB is a symbol used to contain a value. A scalar variable is a variable that contains a single number. A global variable is that variable which is available in the workspace. Local variable is that variable which is created by a function and is not available outside the function. A string variable is composed of text (alphanumeric characters). Logical variables are the variables containing the logical values.

7 Predefined constants

8 The several predefined constants are listed in the table below CommandDescription ansTemporary variable containing the most recent answer. epsSpecifies the accuracy of floating point precision. i,jThe imaginary unit InfInfinity piThe number 3.14 NaNIndicates an undefined numerical result

9 SCALAR OPERATIONS

10 Different operations that MATLAB performs on the scalars are listed, in their order of precedence, in the table below symbolOperationMATLAB form ^Exponentiation a b a^b *Multiplication aba*b /Right division a/ba/b \Left division b/aa\b +Addition a + ba+b -Subtraction a - ba-b

11 The assignment operator

12 The = sign in MATLAB is called the assignment or replacement operator. It is used to assign the numerical values to different variables in MATLAB. The variable on the left-hand side of the = operator is replaced by the right- hand side. General rules of using the = operator.

13 Managing the work session

14 1.clc clears the command window 2.clear Removes all variables from the memory. 3.clear var1 var2 Removes the variables var1 and var2 from the memory. 4.exist (‘name’) Determines if a file or variable exists having the name ‘name’. A 1 indicates that a variable exists and 0 indicates variable does not exists. 5.quit stops MATLAB. 6.who List the variables currently in the memory. 7.whos List the current variables and sizes, and indicates if they have the imaginary parts.

15 8.: Generates an array having regularly spaced elements. 9., separates elements of an array. separates several commands on the same line. 10.; Suppresses screen printing. Denotes a new row in an array. 11.… continues a line 12.Arrow and control keys. 13.Smart recall. 14.Tab completion.

16 COMPLEX NUMBER OPERATIONS

17 MATLAB handels complex number algebra automatically. For example, c 1 = 1- 2i is entered as follow c1 = 1-2i Common errors

18 Formatting commands

19 Table below gives many variants of the format command CommandsDescription and example. format shortFour decimal digits (the default); 13.6745. format long16 digits; 17.27549865424597. format short eFive digits (four decimals) plus exponent; 6.3792e+03. format long e 16 digits(15 decimals) plus exponent; 6.379243784781294e-04. format bankTwo decimal digits; 126.73. format +Positive, negative or zero; +. format ratRational approximations; 43/7. format compactSuppresses some line feeds. format ----------- -- Resets to less compact display.

20 FUNCTIONS

21 The table below lists some of the built- in functions of the MATLAB FunctionMATLAB syntax exex exp(x) sqrt (x) ln xlog(x) log10xLog10(x) cos xcos(x) sin xsin(x) tan xtan(x) cos -1 xacos(x) sin -1 xasin(x) tan -1 xatan(x)


Download ppt "BASICS OF MATLAB Engr.Mian Shahzad Iqbal Lecturer,Telecom Department University of Engineering & Technology Taxila."

Similar presentations


Ads by Google