Docsity

this is tutorial you also know them that way, Thesis of Digital Communication Systems

Partial preview of the text

Download this is tutorial you also know them that way and more Thesis Digital Communication Systems in PDF only on Docsity!

i

About the Tutorial

MATLAB is a programming language developed by MathWorks. It started out as a matrix programming language where linear algebra programming was simple. It can be run both under interactive sessions and as a batch job.

This tutorial gives you aggressively a gentle introduction of MATLAB programming language. It is designed to give students fluency in MATLAB programming language. Problem-based MATLAB examples have been given in simple and easy way to make your learning fast and effective.

Audience

This tutorial has been prepared for the beginners to help them understand basic to advanced functionality of MATLAB. After completing this tutorial you will find yourself at a moderate level of expertise in using MATLAB from where you can take yourself to next levels.

Prerequisites

We assume you have a little knowledge of any computer programming and understand concepts like variables, constants, expressions, statements, etc. If you have done programming in any other high-level language like C, C++ or Java, then it will be very much beneficial and learning MATLAB will be like a fun for you.

Copyright & Disclaimer Notice

Copyright 2014 by Tutorials Point (I) Pvt. Ltd.

All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher.

We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at [email protected]

iii

MATLAB (matrix laboratory) is a fourth-generation high-level programming language and interactive environment for numerical computation, visualization and programming.

MATLAB is developed by MathWorks.

It allows matrix manipulations; plotting of functions and data; implementation of algorithms; creation of user interfaces; interfacing with programs written in other languages, including C, C++, Java, and FORTRAN; analyze data; develop algorithms; and create models and applications.

It has numerous built-in commands and math functions that help you in mathematical calculations, generating plots, and performing numerical methods.

MATLAB's Power of Computational Mathematics

MATLAB is used in every facet of computational mathematics. Following are some commonly used mathematical calculations where it is used most commonly:

 Dealing with Matrices and Arrays  2-D and 3-D Plotting and graphics  Linear Algebra  Algebraic Equations  Non-linear Functions  Statistics  Data Analysis  Calculus and Differential Equations  Numerical Calculations  Integration  Transforms  Curve Fitting  Various other special functions

Features of MATLAB

Following are the basic features of MATLAB:

1. OVERVIEW

 It is a high-level language for numerical computation, visualization and application development.  It also provides an interactive environment for iterative exploration, design and problem solving.  It provides vast library of mathematical functions for linear algebra, statistics, Fourier analysis, filtering, optimization, numerical integration and solving ordinary differential equations.  It provides built-in graphics for visualizing data and tools for creating custom plots.  MATLAB's programming interface gives development tools for improving code quality, maintainability, and maximizing performance.  It provides tools for building applications with custom graphical interfaces.  It provides functions for integrating MATLAB based algorithms with external applications and languages such as C, Java, .NET and Microsoft Excel.

Uses of MATLAB

MATLAB is widely used as a computational tool in science and engineering encompassing the fields of physics, chemistry, math and all engineering streams. It is used in a range of applications including:

 signal processing and Communications  image and video Processing  control systems  test and measurement  computational finance  computational biology

Understanding the MATLAB Environment

MATLAB development IDE can be launched from the icon created on the desktop. The main working window in MATLAB is called the desktop. When MATLAB is started, the desktop appears in its default layout:

The desktop has the following panels:

Current Folder - This panel allows you to access the project folders and files.

Command Window - This is the main area where commands can be entered at the command line. It is indicated by the command prompt (>>).

Workspace - The workspace shows all the variables created and/or imported from files.

MATLAB environment behaves like a super-complex calculator. You can enter commands at the >> command prompt.

MATLAB is an interpreted environment. In other words, you give a command and MATLAB executes it right away.

Hands on Practice

Type a valid expression, for example,

And press ENTER

When you click the Execute button, or type Ctrl+E, MATLAB executes it immediately and the result returned is:

ans = 10

Let us take up few more examples:

3 ^ 2 % 3 raised to the power of 2

When you click the Execute button, or type Ctrl+E, MATLAB executes it immediately and the result returned is:

ans = 9

Another example,

sin(pi /2) % sine of angle 90o

When you click the Execute button, or type Ctrl+E, MATLAB executes it immediately and the result returned is:

ans = 1

3. BASIC SYNTAX

Another example,

7/0 % Divide by zero

When you click the Execute button, or type Ctrl+E, MATLAB executes it immediately and the result returned is:

ans = Inf

warning: division by zero

Another example,

When you click the Execute button, or type Ctrl+E, MATLAB executes it immediately and the result returned is:

ans = 1.4860e+

MATLAB provides some special expressions for some mathematical symbols, like pi for π, Inf for ∞, i (and j) for √-1 etc. Nan stands for 'not a number'.

Use of Semicolon (;) in MATLAB

Semicolon (;) indicates end of statement. However, if you want to suppress and hide the MATLAB output for an expression, add a semicolon after the expression.

For example,

x = 3;

y = x + 5

When you click the Execute button, or type Ctrl+E, MATLAB executes it immediately and the result returned is:

y = 8

Adding Comments

The percent symbol (%) is used for indicating a comment line. For example,

( ) Parentheses; encloses function arguments and array indices; overrides precedence.

[ ] Brackets; enclosures array elements.

. Decimal point.

… Ellipsis; line-continuation operator

, Comma; separates statements and elements in a row

; Semicolon; separates columns and suppresses display.

% Percent sign; designates a comment and specifies formatting.

_ Quote sign and transpose operator.

._ Non-conjugated transpose operator.

= Assignment operator.

Special Variables and Constants

MATLAB supports the following special variables and constants:

Name Meaning

ans Most recent answer.

eps Accuracy of floating-point precision.

i,j The imaginary unit √-1.

Inf Infinity.

NaN Undefined numerical result (not a number).

pi The number π

Naming Variables

Variable names consist of a letter followed by any number of letters, digits or underscore.

MATLAB is case-sensitive.

Variable names can be of any length, however, MATLAB uses only first N characters, where N is given by the function namelengthmax.

Saving Your Work

The save command is used for saving all the variables in the workspace, as a file with .mat extension, in the current directory.

For example,

save myfile

You can reload the file anytime later using the load command.

load myfile