0% found this document useful (0 votes)
48 views5 pages

'Enter Range of Signal X: ' 'Enter Signal X: '

The document contains code to perform various operations on signals including addition, subtraction, multiplication, delaying, advancing, and folding signals. It prompts the user to input ranges and values for signals x and y, performs the selected operation, and plots the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views5 pages

'Enter Range of Signal X: ' 'Enter Signal X: '

The document contains code to perform various operations on signals including addition, subtraction, multiplication, delaying, advancing, and folding signals. It prompts the user to input ranges and values for signals x and y, performs the selected operation, and plots the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 5

n1=input('Enter range of signal x: ');

x=input('Enter signal x: ');


subplot(3,1,1);
stem(n1,x);
title('X') ;
n2=input('Enter range of signal u: ');
y=input('Enter signal y: ');
subplot(3,1,2);
stem(n2,y);
title('Y');
n3 =min (min(n1) ,min( n2 ) ) : max ( max ( n1 ) , max ( n2 ) );
s1 =zeros(1,length (n3) );
s2 =s1;
s1 (find ( ( n3>=min( n1 ) ) & ( n3 <=max ( n1 ) )==1 ) )=x;
s2 (find ( ( n3>=min ( n2 ) ) & ( n3 <=max ( n2 ))==1) )=y;
add=s1 +s2;
subplot(3,1,3)
stem(n3,add)
title('Z=X+Y');
Enter
Enter
Enter
Enter

range of signal x: -2:2


signal x: sin(pi/20*n1)
range of signal u: -5:5
signal y: cos(pi/22*n2)

n1=input('Enter range of signal x: ');


x=input('Enter signal x: ');
subplot(3,1,1);
stem(n1,x);
title('X') ;
n2=input('Enter range of signal y: ');
y=input('Enter signal y: ');
subplot(3,1,2);
stem(n2,y);
title('Y');
n3 =min (min(n1) ,min( n2 ) ) : max ( max ( n1 ) , max ( n2 ) );
s1 =zeros(1,length (n3) );
s2 =s1;
s1 (find ( ( n3>=min( n1 ) ) & ( n3 <=max ( n1 ) )==1 ) )=x;

s2 (find ( ( n3>=min ( n2 ) ) & ( n3 <=max ( n2 ))==1) )=y;


subt=s1 - s2;
subplot(3,1,3)
stem(n3,subt)
title('Z=X - Y');
Enter
Enter
Enter
Enter

range of signal x: -4:4


signal x: sin(pi/20*n1)
range of signal y: -3:3
signal y: cos(pi/22*n2)

n1=input('Enter range of signal x: ');


x=input('Enter signal x: ');
subplot(3,1,1);
stem(n1,x);
title('X') ;
n2=input('Enter range of signal y: ');
y=input('Enter signal y: ');
subplot(3,1,2);
stem(n2,y);
title('Y');
n3 =min (min(n1) ,min( n2 ) ) : max ( max ( n1 ) , max ( n2 ) );
s1 =zeros(1,length (n3) );
s2 =s1;
s1 (find ( ( n3>=min( n1 ) ) & ( n3 <=max ( n1 ) )==1 ) )=x;
s2 (find ( ( n3>=min ( n2 ) ) & ( n3 <=max ( n2 ))==1) )=y;
mult=s1.*s2;
subplot(3,1,3)
stem(n3,mult)
title('Z=X*Y');

Enter range of signal x: -4:4


Enter signal x: sin(pi/20*n1)
Enter range of signal y: -3:3
Enter signal y: cos(pi/22*n2)

clc
clear all
n1=input('Enter amount to be delayed: ');
n2=input('Enter amount to be advanced: ');
n=-2:2;
x=input('Enter signal: ');
subplot(3,1,1);
stem(n,x);
title('x(n)');
m=n+n1;
y=x;
subplot(3,1,2);
stem(m,y);
title('delayed signal x(n-n1)');
t=n-n2;
z=x;
subplot(3,1,3);
stem(t,z);
title('advanced signal x(n+n2)');

Enter amount to be delayed: 2


Enter amount to be advanced: 3
Enter signal: sin(pi/20*n)

clc
clear all
n=-2:2;
x=input('Enter signal: ');
subplot(2,1,1);
stem(n,x);
title('x(n)');
m=(-1).*n;
y=x;
subplot(2,1,2);
stem(m,y);
title('Folded signal');
Enter signal: sin(pi/32*n)

You might also like