Sie sind auf Seite 1von 2

PROGRAM2

AIM: Write a program for the following signals in discrete time domain.
1.Unit Step
2.Exponential
3.Unit Impulse
4.Sine
5.Cosine
6.Signum
7.Ramp
8.Rectangle
%unit step
n=-5:1:5; %cosine
x0=0; y4=cos(n)
x1=1; subplot(2,4,5);
y=x1.*(n>=0)+x0.*(n<0); stem(n,y4);
subplot(2,4,1); xlabel('time');
stem(n,y); ylabel('amplitude');
xlabel('time'); title('discrete cosine function');
ylabel('magnitude');
title('discrete step signal)'); %signum
n=-5:1:5;
%exponential y5=[-ones(1,5),zeros(1,1), ones(1,5)];
a=2; subplot(2,4,6);
y1=exp(a*n); plot(n,y5);
subplot(2,4,2); xlabel('time');
stem(n,y1); ylabel('amplitude');
xlabel('time'); title('discrete signum function');
ylabel('magnitude');
title('discrete with increasing exponential signal %ramp
'); y6=n;
subplot(2,4,7);
%unit impulse stem(n,y6);
y2=x1.*(n==0)+x0.*(n<0)+x0.*(n>0) ; label('time');
subplot(2,4,3); ylabel('amplitude');
stem(n,y2); title('discrete ramp function');
xlabel('time');
ylabel('magnitude'); %rectangle
title('discrete unit impulse'); n=-10:1:10;
f=0.3;
%sine x3=sin(2*f*n);
y3=sin(n) x4=-1;
subplot(2,4,4); y7=x4*(x3<0)+x1*(x3>0)+x0*(x3==0);
stem(n,y3); subplot(2,4,8);
xlabel('time'); stem(n,y7);
ylabel('amplitude'); xlabel('time');
title('discrete sine function'); ylabel('magnitude');
title('discrete rectangle function');

Name :Tushar Sharma


Roll No. :17EJCEC864
PROGRAM2

PROGRAM CODE

Name :Tushar Sharma


Roll No. :17EJCEC864

Das könnte Ihnen auch gefallen