Net 222: Communications and networks fundamentals ( Practical Part)

45
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Tutorial 2 : Matlab - Getting Started Networks and Communication Department 1

description

Net 222: Communications and networks fundamentals ( Practical Part). Tutorial 2 : Matlab - Getting Started. Lecture Contents. Getting Started. The MATLAB Desktop. Command window. Command History window. Current Folder window. Workspace window. Matlab menu bar. - PowerPoint PPT Presentation

Transcript of Net 222: Communications and networks fundamentals ( Practical Part)

Page 1: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART)Tutorial 2 : Matlab - Getting Started

1

Page 2: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

2

Lecture Contents Getting Started.

The MATLAB Desktop. Command window. Command History window. Current Folder window. Workspace window. Matlab menu bar.

Page 3: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

3

Matrix Laboratory Matlab = Matrix Laboratory A software environment for interactive numerical

computations Examples:

Matrix computations and linear algebra Solving nonlinear equations Numerical solution of differential equations Mathematical optimization Statistics and data analysis Signal processing Modelling of dynamical systems Solving partial differential equations Simulation of engineering systems

Page 4: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

4

MATLAB Toolboxes MATLAB has a number of add-on software

modules, called toolboxes, that perform more specialized computations. Signal & Image Processing

Signal Processing- Image Processing Communications – System Identification - Wavelet Filter Design

Control DesignControl System - Fuzzy Logic - Robust Control - μ-Analysis and Synthesis - LMI Control Model Predictive Control More than 60 toolboxes!

Page 5: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

5

Simulink Simulink - a package for modeling

dynamic systems.

Page 6: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

6

Simulink (Cont.) Analyzing results:

Page 7: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

7

Getting Started. MATLAB offers engineers, scientists, and

mathematicians an intuitive language for expressing problems and their solutions mathematically and graphically.

It integrates computation, visualization, and programming in a flexible, open environment.

Complex numeric and symbolic problems can be solved in a fraction of the time required with other languages such as C, Fortran, or Java.

Page 8: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

8

The MATLAB Desktop MATLAB has an extensive graphical

user interface. When MATLAB starts, the main MATLAB window appears.

The Desktop menu controls the layout and appearance of the windows and gives you a list of the windows you can use.

Page 9: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

9

Page 10: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

10

The MATLAB environment is command oriented

Page 11: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

11

The first four appear by default, the first time you use MATLAB.

Page 12: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

12

The Start button in the bottom left corner of the MATLABDesktop brings up demos, tools, and other windows.

Page 13: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

13

All MATLAB windows are docked in the default desktop,which means that they are tiled on the main MATLABwindow.

Docked window

Undocked window

Page 14: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

14

Command window

MATLAB expressions and statements are evaluated as you type them in the Command Window, and results of the computation are displayed there too.

Page 15: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

15

Command window MATLAB expressions and statements are

evaluated as you type them in the Command Window, and results of the computation are displayed there too.

Expressions and statements are also used in M-files (see it later).

They are usually of the form:

or simply:

Page 16: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

16

Command window (Cont.) Expressions are usually composed from

operators, functions, and variable names.

Evaluation of the expression produces a matrix (or other data type), which is then displayed on the screen or assigned to a variable for future use.

If the variable name and = sign are omitted, a variable ans (for answer) is automatically created to which the result is assigned.

Page 17: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

17

Command window (Cont.) A statement is normally terminated at the

end of the line. However, a statement can be continued to the next line with three periods (...) at the end of the line.

Several statements can be placed on a single line separated by commas or semicolons.

MATLAB is case-sensitive in the names of commands, functions, and variables, so A and a are two different variables.

Page 18: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

18

Command window (Cont.) A comma or blank separates the

elements within a row of a matrix (sometimes a comma is necessary to split the expressions, because a blank can be ambiguous).

A semicolon ends a row.

Page 19: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

19

Command window (Cont.) You can save the Command Window dialog with the

diary command:

This causes what appears subsequently in the Command Window to be written to the named file (if the filename is omitted, it is written to a default file named diary) until you type the command diary off; the command diary on causes writing to the file to resume.

When finished, you can edit the file as desired and print it out.

Page 20: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

20

Command window (Cont.) Tab completion is another helpful

shortcut. It works in both the Command Window and the Editor.

Start typing a command name, a variable name, or a filename. Before you type it all in, hit the tab key. Try typing z then a tab. A list of all the functions and variables that start with z will pop up. Select one from the list, or keep typing to narrow down the selection.

Page 21: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

21

Command window (Cont.) You can clear the Command Window with

the clccommand or with Edit > Clear Command Window.

Page 22: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

22

Command History window

This window lists the commands typed in so far. You can re-execute one more commands from this window by double-clicking or dragging the command(s) into the Command Window.

Page 23: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

23

Current Folder window

The Current Folder window displays a list of the files inyour current folder. The name of this folder also appears atthe top of the main MATLAB window, in the MATLAB Toolbar. Your current folder is the first place MATLABlooks for your M-files, and for workspace (.mat) filescontaining data that you load and save.MATLAB also looks in all the folders in your MATLAB path. Folders that are not on your MATLAB pathare shown in gray.

Page 24: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

24

Current Folder window (Cont.) The commands: pwd returns the name of the current folder. cd changes the current folder. dir lists the contents of the current folder, what lists only the MATLAB-specific files in the folder grouped by file type. delete and type can be used to delete a file and display a file in the Command Window, respectively.

Page 25: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

25

Workspace window

The Workspace window lists variables that you have eitherentered or computed in your MATLAB session.

Page 26: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

26

Workspace window (Cont.) All the matrices and other variables that

you create, except those internal to M-files, are shown in your Workspace window.

Double-clicking on a variable in the Workspace window pulls up the Variable Editor.

Page 27: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

27

Workspace window (Cont.) The command: whos lists the variables currently in the workspace.clear variablename clear a variable or a function from the workspace. (or by right-clicking the variable in the Workspace window and selecting Delete)clear clears all variables from the workspace.

Page 28: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

28

Workspace window (Cont.) When you log out or exit MATLAB, all

variables are lost. However, invoking the command save before exiting writes all variables to a binary file named matlab.mat in the current folder.

When you later reenter MATLAB, the command load restores the workspace to its former state.

Page 29: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

29

Matlab menu bar

Page 30: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

30

Matlab menu bar(Cont.)

Page 31: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

31

Matlab menu bar (Cont.)

Page 32: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

32

Matlab menu bar (Cont.)

Page 33: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

33

Matlab menu bar (Cont.)

Page 34: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

34

Matlab menu bar (Cont.)

Page 35: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

35

Matlab menu bar (Cont.)

Page 36: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

36

Some Useful MATLAB commands

Page 37: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

37

Math MATLAB can do simple math just as a

calculator.

Page 38: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

38

Interactive Calculations Matlab is interactive, no need to declare

variables.

Most elementary functions and constants are already defined.

Page 39: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

39

Functions MATLAB has many built-in functions. Some math functions are:

Page 40: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

40

The Help System

Page 41: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

41

The help system example

Page 42: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

42

MATLAB Variable Names Variable names ARE case sensitive Variable names can contain up to 63

characters (as of MATLAB 6.5 and newer) Variable names must start with a letter

followed by letters, digits, and underscores.

Page 43: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

43

MATLAB Special Variables

Page 44: Net 222: Communications and networks fundamentals  ( Practical Part)

Networks and Communication Department

44

MATLAB Math & Assignment Operators

Page 45: Net 222: Communications and networks fundamentals  ( Practical Part)

45

Networks and Communication Department

Any Questions ?The End