1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Digital Signal Processing : Introduction to MATLAB pot

33 432 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 33
Dung lượng 367 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

BEIT, 6th SemesterMatlab Basics... A/B is valid and equals A.B -l for same size square matrices A & B... Few methods to create vector LINSPACEx1, x2: generates a row vector of 100 linea

Trang 3

-External Interface

-Optional Toolbox for Signal Processing,

System analysis, Image Processing

Trang 4

How many windows?

Trang 5

BEIT, 6th Semester

MATLAB Windows

characterized by ‘>>’ command prompt

 Edit window: where programs are written

and saved as ‘M-files’

 Graphics window: shows figures,

alternately known as Figure window

Trang 6

Command Window

Figure Window

Edit Window

Trang 7

BEIT, 6th Semester

Matlab Basics

Trang 8

MATLAB Basics: Variables

 Variables:

-Variables are assigned numerical values

by typing the expression directly

Trang 10

 Global Variables

 Local Variables

Trang 12

 Matrices : Basic building block

 Elements are entered row-wise

Trang 13

BEIT, 6th Semester

Basics Matrices

 Special Matrices

null matrix: M = [];

nxm matrix of zeros: M = zeros(n,m);

nxm matrix of ones: M = ones(n,m);

nxn identity matrix: M = eye(n);

Try these Matrices

[eye(2);zeros(2)],[eye(2);zeros(3)], [eye(2),ones(2,3)]

Trang 14

Matrix Operations

 Matrix operations:

A+B is valid if A and B are of same size A*B is valid if A’s number of columns equals B’s number of rows.

A/B is valid and equals A.B -l for same size square matrices A & B.

 Element by element operations:

.* , / , ^ etc

a = [1 2 3], b = [2 2 4],

Trang 15

BEIT, 6th Semester

Vectors

Trang 16

Few methods to create vector

LINSPACE(x1, x2): generates a row vector of 100 linearly equally spaced points between x1 and x2.

LINSPACE(x1, x2, N): generates N points

between x1 and x2.

LOGSPACE(d1, d2): generates a row vector of 50

logarithmically equally spaced points between

decades 10^d1 and 10^d2.

Trang 17

BEIT, 6th Semester

Waveform representation

Trang 18

2D Plotting

plot: creates linear continuous plots of

vectors and matrices;

plot(t,y): plots the vector t on the x-axis

versus vector y on the y-axis

 To label your axes and give the plot a title, type

xlabel('time (sec)') ylabel('step response') title('My Plot')

 Change scaling of the axes by using the

Trang 20

Example: Draw sine wave

Trang 21

BEIT, 6th Semester

Matlab Plot

Trang 22

Example: Discrete time signal

Trang 23

BEIT, 6th Semester

Matlab Plot

Trang 24

Example: Draw unit step and delayed

unit step functions

 n=input('enter value of n')

 t=0:1:n-1;

 y1=ones(1,n); %unit step

 y2=[zeros(1,4) ones(1,n-4)]; %delayed unit step

Trang 25

BEIT, 6th Semester

Matlab Plot

Trang 26

Functions

Trang 27

BEIT, 6th Semester

Scripts and Functions

 Script files are ‘M-files’ with some valid

MATLAB commands

 Generally work on global variables present

in the workspace

 Results obtained after executing script

files are left in the workspace

Trang 28

Scripts and Functions

 Function files are also ‘M-files’ but with local variables

 Syntax of defining a function

function [output variable] =

function_name (input variable)

 File name should be exactly same as function name

Trang 29

BEIT, 6th Semester

Example : user defined function

 Assignment is the method of giving a value to a variable You have already seen this in the

interactive mode We write x=a to give the value

of a to the value of x Here is a short program

illustrating the use of assignment

Trang 30

Loops, flows:

for m=1:10:100

num = 1/(m + 1) end

Trang 31

BEIT, 6th Semester

Recapitulate

Trang 32

Few in-built Matlab functions

Trang 33

BEIT, 6th Semester

Practice

1>Draw a straight line satisfying the equation: y = 3*x + 10

2> Create matrices with zeros, eye and ones

3>Draw a circle with radius unity (use cos θ for x axis, sin θ for y axis)

4>Draw a cosine wave with frequency 10kHz Use both ‘plot’ and

‘stem’ functions to see the difference.

5>Multiply two matrices of sizes 3x3.

6>Plot the parametric curve x(t) = t, y(t) = exp(-t/2) for 0<t<pi/2

using ezplot

7>Plot a cardioid r(θ) = 1 + cos(θ) for 0< θ <pi/2

Ngày đăng: 28/06/2014, 06:20

TỪ KHÓA LIÊN QUAN