Sunteți pe pagina 1din 8

Program No:-6 AIM: -To perform manipulations of signals: Addition, Multiplication, Folding, Shifting using MATLAB.

SOFTWARE REQURIED:MATLAB R2007b (7.5 Version). PROCEDURE:- (1). Open MATLAB. (2). Open new M- file. (3). Write the program in Editor Space. (4). Save in current directory and add it to the path. (5). Run the program. (6). For the output see command window. PROGRAM:clc; close all; clear all; a=input('Enter the value of Matrix a '); b=input('Enter the value of Matrix b '); disp('The matrix a= ');a disp('The matrix b= ');b % to find sum of a and b c=a+b; disp('The sum of a and b is ');c %to find multiplication of a and b d=a*b; disp('The product of a and b is ');d t=0:0.001:1; L=length(t); f1=1; f2=3; x1=sin(2*pi*f1*t); x2=sin(2*pi*f2*t); figure; subplot(3,2,1); plot(t,x1,'b',t,x2,'r'); title('the signals x1(t) and x2(t) <Nidhi>'); t=-1:0.001:0; x3=sin(2*pi*f1*(-t)); x4=sin(2*pi*f2*(-t)); subplot(3,2,4); plot(t,x3,'b',t,x4,'r'); title('the folding of x1(t)and x2(t) <Nidhi>'); x5=[zeros(1,200),x2(1:(L-200))]; subplot(3,2,5); plot(t,x5); title('the shifting of x1(t)and x2(t) <Nidhi>');

INPUT:- Enter the value of Matrix a [1 2 -9 ; 2 -1 2; 3 -4 3] Enter the value of Matrix b [1 2 3; 4 5 6; 7 8 9] The matrix a= 1 2 -9 2 -1 2 3 -4 3 The matrix b= 1 2 3 4 5 6 7 8 9 The sum of a and b is c= 2 4 -6 6 4 8 10 4 12 The product of a and b is d= -54 -60 -66 12 15 18 8 10 12 OUTPUT:-

RESULT:- Manipulations of signals were observed with the above program in MATLAB.

Program No:-7 AIM: - To write a MATLAB program to verify the given system is linear or non linear. SOFTWARE REQURIED:MATLAB R2007b (7.5 Version). PROCEDURE:- (1). Open MATLAB. (2). Open new M- file. (3). Write the program in Editor Space. (4). Save in current directory and add it to the path. (5). Run the program. (6). For the output see command window. PROGRAM:clc; clear all; close all; x1=input('enter the x1[n] sequence='); x2=input('enter the x2[n] sequence='); if length(x1)~=length(x2) disp(' length of x2 must be equal to the length of x1'); return; end; h=input('enter the h[n] sequence='); a=input('enter the constant a= '); b=input('enter the constant b= '); y01=conv(a*x1,h); y02=conv(b*x2,h); y1=y01+y02; x=a*x1+b*x2; y2=conv(x,h); L=length(x1)+length(h)-1; n=0:L-1; subplot(2,1,1); stem(n,y1); xlabel('n --->');ylabel('amp ---->'); title('sum of the individual response <Nidhi>'); subplot(2,1,2); stem(n,y2); xlabel('n --->'); ylabel('amp ---->'); title('total response <Nidhi>'); if y1==y2 disp('the system is a Linear system'); else disp('the system is a non-linear system'); end;

INPUT:- enter the x1[n] sequence=[1 2 3 4] enter the x2[n] sequence=[1 -2 3 -5] enter the h[n] sequence=[1 -4 0 2 -4 1] enter the constant a= 3 enter the constant b= 2 OUTPUT:the system is a Linear system

RESULT:- The MATLAB Program of verifying the system is linear or non linear by using MATLAB has been performed.

Program No:-8 AIM: - To write a MATLAB program to verify the given system is Time invariant or Timevariant. SOFTWARE REQURIED:MATLAB R2007b (7.5 Version). PROCEDURE:- (1). Open MATLAB. (2). Open new M- file. (3). Write the program in Editor Space. (4). Save in current directory and add it to the path. (5). Run the program. (6). For the output see command window. PROGRAM:clc; clear all; close all; x=input('enter the sequence x[n]='); h=input('enter the sequence h[n]='); d=input('enter the positive number for delay d='); y=conv(x,h); % actual output ydn=[zeros(1,d),y]; % delayed output xdn=[zeros(1,d),x]; % delayed input yn=conv(xdn,h); % output for delayed input figure; subplot(2,1,1); stem(0:length(x)-1,x); xlabel('n ---->'),ylabel('amp --->'); title('the sequence x[n] <Nidhi> '); subplot(2,1,2); stem(0:length(xdn)-1,xdn); xlabel('n ---->'),ylabel('amp --->'); title('the delayed sequence of x[n] <Nidhi> '); figure; subplot(2,1,1); stem(0:length(yn)-1,yn); xlabel('n ---->'),ylabel('amp --->'); title('the response of the system to the delayed sequence of x[n] <Nidhi> '); subplot(2,1,2); stem(0:length(ydn)-1,ydn); xlabel('n ---->'),ylabel('amp --->'); title('the delayed output sequence <Nidhi> '); if yn==ydn disp('the given system is a Time-invarient system'); else disp('the given system is a Time-varient system'); end;

INPUT:enter the sequence x[n]=[0 2 3 1 -2 7 3] enter the sequence h[n]=[4 -5 -11 -3 7 2 6 8 -15] enter the positive number for delay d=5 OUTPUT:the given system is a Time-invarient system

RESULT:- Hence from above program we are able to compute that the given system is time variant or invariant depending on their response for actual and delayed signal.

S-ar putea să vă placă și