×
DON'T LET YOURSELF DOWN
--Your friends at LectureNotes
Close

Lab Manuals for Software Engineering - SE By Shreya Chakraborty

  • Software Engineering - SE
  • Practical
  • 6 Views
  • Uploaded 20 days ago
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

Experiment No.: 2 Date: 23-07-2019 Aim of the Experiment: Solution of difference equation to analyze an LTI system. (Using Filter command and also using Z-transform method). System and Software Requirement: 1. MATLAB 9.6.0.1092380 (R2019a) Update 1 Theory: In mathematics and signal processing, the Z-transform converts a discrete-time signal, which is a sequence of real or complex numbers, into a complex frequency-domain representation. It can be considered as a discrete-time equivalent of the Laplace transform. Given a finite length signal, the z-transform is defined as where, the sequence support interval is [0, N], and z is any complex number. This transformation produces a new representation of x[n] denoted X(z). Returning to the original sequence (inverse z-transform) x[n] requires finding the coefficient associated with the nth power z-1. ztrans(f) finds the Z-Transform of ‘f’. By default, the independent variable is n and the transformation variable is z. If f does not contain n, ztrans uses symvar. ztrans(f,transVar) uses the transformation variable transVar instead of z. ztrans(f,var,transVar) uses the independent variable var and transformation variable transVar instead of n and z, respectively.    If any argument is an array, then ztrans acts element-wise on all elements of the array. If the first argument contains a symbolic function, then the second argument must be a scalar. To compute the inverse Z-transform, use iztrans. y = filter(b,a,x) filters the input data x using a rational transfer function defined by the numerator and denominator coefficients b and a.  If a(1) is not equal to 1, then filter normalizes the filter coefficients by a(1). Therefore, a(1) must be nonzero.  If x is a vector, then filter returns the filtered data as a vector of the same size as x.  If x is a matrix, then filter acts along the first dimension and returns the filtered data for each column.  If x is a multidimensional array, then filter acts along the first array dimension whose size does not equal 1. Code: <Impulse Response, Filtered Step Response and Determination of Stability> n= -20:100; b= 1; a= [1, -1, 0.9]; % Impulse Response h= impz(b, a, n); subplot(211),stem(n,h); title('Impulse Response'); xlabel('n'); ylabel('h(n)'); legend('1729058');

Text from page-2

% Step Response x= stepseq(0, -20, 100); s= filter(b,a,x); subplot(212),stem(n,s); title('Step Response'); xlabel('n'); ylabel('s(n)'); legend('1729058'); % Stability p= roots(a); % Roots of quadratic equation 'a' magp= abs(p); % Absolute Value of 'a' if magp < 1 disp('Stable'); else disp('Unstable'); end <Noisy Signal and use of Filter Function> clc; clear all; close all; rng default; t= linspace(-pi, pi, 100); x= sin(t); y= x+ 0.28391624.*rand(size(t)); windowSize= 9; b=(1/windowSize)*ones(1,windowSize); a=1; z= filter(b,a,y); subplot(121),plot(t,x); xlabel('t'); ylabel('Sin(t)'); title('Original Signal'); legend('1729057', 'Location', 'Southeast'); subplot(122),plot(t,y); hold on; plot(t,z); grid on; legend('Input data', 'Filtered Data', 'Location', 'Southeast'); title('Input and Filtered Signal'); Plots: Fig 1: Impulse Response, Filtered Step Response

Text from page-3

Fig 2: Sine Curve, Noisy and Filtered Signal Conclusion: Thus we calculated solution of difference equation to analyze an LTI system using z-transform and filter function. All the outputs and waveforms are verified. Name: Saptarshi Mazumdar Roll No.: 1729058 Section: CSCE-1

Text from page-4

Experiment No.: 1 Date: 16-07-2019 Aim of the Experiment: Familiarization of MATLAB and Basic commands like Matrix operation, Condition, Loop, Function etc. Generation and Plotting of basic Signals and operation on them. System and Software Requirement: 1. MATLAB 9.6.0.1092380 (R2019a) Update 1 Theory: The matrix-based MATLAB language is the world’s most natural way to express computational mathematics. Built-in graphics make it easy to visualize and gain insights from data. The desktop environment invites experimentation, exploration, and discovery. These MATLAB tools and capabilities are all rigorously tested and designed to work together. MATLAB operates primarily on arrays and matrices, both in whole and in part. A matrix is a two-dimensional array often used for linear algebra. A vector is a special case of a matrix. The purpose of this section is to show how to create vectors and matrices in MATLAB. As discussed earlier, an array of dimension 1 ×n is called a row vector, whereas an array of dimension m × 1 is called a column vector. The elements of vectors in MATLAB are enclosed by square brackets and are separated by spaces or by commas. Column vectors are created in a similar way, however, semicolon (;) must separate the components of a column vector. On the other hand, a row vector is converted to a column vector using the transpose operator. The transpose operation is denoted by an apostrophe or a single quote (’). The simplest form of the “if statement” in MATLAB is, if expression statements end In the “for ... end loop”, the execution of a command is repeated at a fixed and predetermined number of times. The syntax is, for variable = expression statements end Functions are programs (or routines) that accept input arguments and return output arguments. Each M-file function (or function or M-file for short) has its own area of workspace, separated from the MATLAB base workspace. MATLAB has an excellent set of graphic tools. Plotting a given data set or the results of computation is possible with very few commands. You are highly encouraged to plot mathematical functions and results of analysis as often as possible. Trying to understand mathematical equations with graphics is an enjoyable and very efficient way of learning mathematics. The MATLAB command to plot a graph is plot(x,y). >> x = [1 2 3 4 5 6]; >> y = [3 -1 2 4 5 1]; >> plot(x,y);

Lecture Notes