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

Digital Signal Processing : Introduction to MATLAB pot

33 432 0

Đ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

Nội dung

BEIT, 6th Semester Digital Signal Processing : Introduction to MATLAB Ms. T. Samanta Lecturer Department of Information Technology BEIT, 6th Semester Books:  “Getting Started with MATLAB” - Rudra Pratap  “Digital Signal Processing ” - Sanjit K. Mitra.  “Digital Signal Processing-A Practitioner’s Approach” - Kaluri V. Rangarao - Ranjan K. Mallik BEIT, 6th Semester IntroductionMATLAB -> MATrix LABoratory  Built-in Functions -Computations -Graphics -External Interface -Optional Toolbox for Signal Processing, System analysis, Image Processing BEIT, 6th Semester How many windows? BEIT, 6th Semester MATLAB Windows  Command window: main window characterized by ‘>>’ command prompt.  Edit window: where programs are written and saved as ‘M-files’.  Graphics window: shows figures, alternately known as Figure window. BEIT, 6th Semester Command Window Figure Window Edit Window BEIT, 6th Semester Matlab Basics BEIT, 6th Semester MATLAB Basics: Variables  Variables: -Variables are assigned numerical values by typing the expression directly >> a = 1+2 press enter >> a = 3 >> a = 1+2; suppresses the output BEIT, 6th Semester Variables  several predefined variables i sqrt(-1) j sqrt(-1) pi 3.1416  >> y= 2*(1+4*j) >> y= 2.0000 + 8.0000i BEIT, 6th Semester Variables  Global Variables  Local Variables [...]... command:axis([xmin xmax ymin ymax]);  plot: 2D Plotting  stem(k,y ): for discrete-time signals this command is used  To plot more than one graph on the screen, subplot(m,n,p ): breaks the Figure window into an m-by-n matrix of small axes, selects the p-th sub-window for the current plot  grid : shows the underlying grid of axes BEIT, 6th Semester Example: Draw sine wave      t=-2*pi:0. 1:2 *pi;... B  Element by element operations: * , / , ^ etc a = [1 2 3], b = [2 2 4], =>do a.*b and a*b BEIT, 6th Semester Vectors BEIT, 6th Semester 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... time') ylabel(' > sin(t)') BEIT, 6th Semester Matlab Plot BEIT, 6th Semester Example: Discrete time signal      t=-2*pi:0. 5:2 *pi; y=1.5*sin(t); stem(t,y); xlabel(' > time') ylabel(' > sin(t)') BEIT, 6th Semester Matlab Plot BEIT, 6th Semester 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)... equally spaced points between decades 10^d1 and 10^d2  a = 0:2 :1 0 generates a row vector of 6 equally spaced points between 0 and 10 BEIT, 6th Semester Waveform representation BEIT, 6th Semester 2D Plotting 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.. .MATLAB Basics:  Arithmetic operators: + addition, - subtraction, * multiplication, /division, ^ power operator, ' transpose BEIT, 6th Semester Matrices  Matrices : Basic building block  Elements are entered row-wise >> v = [1 3 5 7] creates a 1x4 vector >> M = [1 2 4; 3 6 8] creates a 2x3 matrix >> M(i,j) => accesses the element... Run  a =[10 10 10]; d = [3 3 3]; Another m file to access  mod(a,d); above function BEIT, 6th Semester Loops, flows: for m= 1:1 0:1 00 num = 1/(m + 1) end %i is incremented by 10 from 1 to 100 I = 6; j = 21 if I > 5 k = I; elseif (i>1) & (j == 20) k = 5*I + j else k = 1; end %if statement BEIT, 6th Semester Recapitulate BEIT, 6th Semester Few in-built Matlab functions sin() cos() log() asin() acos()... and jth column BEIT, 6th Semester Basics Matrices  Special Matrices null matrix: nxm matrix of zeros: nxm matrix of ones: nxn identity matrix: M M M M = = = = []; zeros(n,m); ones(n,m); eye(n); Try these Matrices [eye(2);zeros(2)],[eye(2);zeros(3)], [eye(2),ones(2,3)] BEIT, 6th Semester 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... variable] = function_name (input variable)  File name should be exactly same as function name 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 function r=mod(a,d)  %If a and d are integers,... Matlab command window, press enter This will display the function definition Study the definition of each function 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. .. stem(t,y1,'filled');ylabel('amplitude'); xlabel('n ->');ylabel('amplitude'); subplot(2,1,2); stem(t,y2,'filled'); xlabel('n ->');ylabel('amplitude'); BEIT, 6th Semester Matlab Plot BEIT, 6th Semester Functions 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 . Semester Digital Signal Processing : Introduction to MATLAB Ms. T. Samanta Lecturer Department of Information Technology BEIT, 6th Semester Books:  “Getting Started with MATLAB - Rudra Pratap  Digital. Pratap  Digital Signal Processing ” - Sanjit K. Mitra.  Digital Signal Processing- A Practitioner’s Approach” - Kaluri V. Rangarao - Ranjan K. Mallik BEIT, 6th Semester Introduction  MATLAB ->. 6th Semester MATLAB Basics:  Arithmetic operators: + addition, - subtraction, * multiplication, /division, ^ power operator, ' transpose BEIT, 6th Semester Matrices  Matrices : Basic building

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

TỪ KHÓA LIÊN QUAN