Basic Programs used in Digital Signal Processing using MATLAB
%Unit step%
n=-99:1:100;
u=[zeros(1,100) ones(1,100)];
plot (n,u);
stem (n,u);
%Ramp%
n1=input('enter the limit');
n2=0:n1;
stem(n2,n2)
%real exponential%
n=0:35;
a=1.2;
k=.2;
x=k*a.^+n;
stem (n,x);
%complex exponential%
n=-10:1:10;
alpha=-.1+.3j;
x=exp(alpha*+n);
subplot(2,2,1);stem(n,real(x))
subplot(2,2,2);stem(n,imag(x))
subplot(2,2,1);stem(n,abs(x))
subplot(2,2,1);stem(n,(180/pi)*angle(x))
%sine wave%
t=0:.01:1;
x=sin(2*pi*t);
plot(t,x);
stem(n,x);
n=-99:1:100;
u=[zeros(1,100) ones(1,100)];
plot (n,u);
stem (n,u);
%Ramp%
n1=input('enter the limit');
n2=0:n1;
stem(n2,n2)
%real exponential%
n=0:35;
a=1.2;
k=.2;
x=k*a.^+n;
stem (n,x);
%complex exponential%
n=-10:1:10;
alpha=-.1+.3j;
x=exp(alpha*+n);
subplot(2,2,1);stem(n,real(x))
subplot(2,2,2);stem(n,imag(x))
subplot(2,2,1);stem(n,abs(x))
subplot(2,2,1);stem(n,(180/pi)*angle(x))
%sine wave%
t=0:.01:1;
x=sin(2*pi*t);
plot(t,x);
stem(n,x);