Posts

Showing posts from October, 2021

Verification of Commutative, Distributive and Associative Property of Linear Convolution in MATLAB

Image
  MATLAB Program to verify the linear convolution between two discrete sequences and also verify the Commutative, Distributive and Associative properties of linear convolution where, x1[n] = {1, 0 ,1,0}; x2[n] = {1,2, 1 ,2} & x3[n] = { 1 ,-1,1,-1} (underline indicates the value at the zero index). Copy and paste the code in the Editor to run the code. Program Code: clc; clear all; close all; n1 = input("\n enter the time index of x1: "); x1 = input(" enter the dicrete sequence x1: "); n2 = input("\n enter the time index of x2: "); x2 = input(" enter the dicrete sequence x2: "); n3 = input("\n enter the time index of x3: "); x3 = input(" enter the dicrete sequence x3: "); % Plot of three discrete sequences subplot(3,3,1); stem(n1,x1); xlabel('time index'); ylabel('amplitude'); title('discrete sequence of x1'); subplot(3,3,4); stem(n2,x2); xlabel('time index'); ylabel('amplitude'); tit...

Arithmetic operations of different discrete time signals. I. Time Shifting II. Folding/ Symmetry of the signal III. Addition IV. Multiplication V. Time scaling in MATLAB

Image
  MATLAB Program to verify the time-shifting property of discrete time signals where, x1[n] = {1, 0 ,1,0} & x2[n] = {1,2, 1 ,2} (underline indicates the value at the zero index) by plotting:  A. x1[n]+x2[n]  B. x1[n].*x2[n]  C. x1[-n+2]  D. x2[-n-2]  E. x1[-n+2].*x2[-n-2] Copy and paste the following program code in the Editor to run the program. Program Code: % Plot of the two discrete sequences n1 = [-1:2]; x1 = [1 0 1 0]; subplot(4,2,1); stem(n1,x1); xlabel('time index'); ylabel('amplitude'); title('discrete time sequence of x1'); axis([-2 2 0 3]); n2 = [-2:1]; x2 = [1 2 1 2]; subplot(4,2,3); stem(n2,x2); xlabel('time index'); ylabel('amplitude'); title('discrete time sequence of x2'); axis([-2 2 0 3]); % Addition of the two sequences n3 = [min(min(n1,n2)):max(max(n1,n2))]; z1 = [zeros((length(n3)-length(x1))),x1]; z2 = [x2,zeros((length(n3)-length(x2)))]; z3 = z1 + z2; subplot(4,2,5); stem(n3,z3); xlabel('time index'); yla...

Realization of Discrete signals using MATLAB

Image
  MATLAB Program to plot Unit Step, Unit Impulse, Exponential, Sine and Sinc functions. Copy the following program code and paste in your MATLAB or any other similar software's Editor to run the code. Program Code: % UNIT INPULSE FUNCTION n = -5:5; r = [zeros(1,5),ones(1,1),zeros(1,5)]; subplot(2,3,1); stem(n,r); xlabel('time index'); ylabel('amplitude'); title('Unit Impluse Function'); % UNIT STEP FUNCTION n = -5:5; r = [zeros(1,5),ones(1,6)]; subplot(2,3,2); stem(n,r); xlabel('time index'); ylabel('amplitude'); title('Unit Step Function'); % EXPONENTIAL FUNCTION n = -5:5; a = 1; r = exp(a*n); subplot(2,3,4) stem(n,r); xlabel('time index'); ylabel('amplitude'); title('Exponential Function'); % SINUSOIDAL FUNCTION n = -5:5; r = sin(n); subplot(2,3,5) stem(n,r); xlabel('time index'); ylabel('amplitude'); title('Sinusoidal Function'); % SINC FUNCTION n = -10:10; r = sinc(n*.2); subplot(2,...