CT and DT Operations
CT and DT Operations
The following matlab code performs time scaling, shifting and reversal
clc;
n=[l:u];
clear;
end
subplot(3,1,2);
u=l+s-1;
j=1;
%for loop for a random sequence
n=[l:u];
for i=l:1:u
xn(j)=ceil(5*rand+2);
j=j+1;
j=1;
%abs(a)>1 - compression
if abs(a)~=1 && abs(a)>1
for i=1:1:length(n)
k=n(i)/a;
if k-fix(k) == 0
end
n1(j)=k;
subplot(3,1,1);
xn1(j)=xn(i);
stem(n,xn);
disp(k);
grid on;
j=j+1;
xlabel(n); ylabel(x[n]);
end
%plot x[an+k]
a=input('Enter the scaling factor');
k=input('Enter shifting factor');
end
if a<0
xn1=fliplr(xn1);
end
subplot(3,1,3);
stem(n1,xn1);grid on;
xlabel(n);ylabel(x[an]);
title(Compressed sequence);
end
%abs(a)<1 - expansion
if abs(a)~=1 && abs(a)<1
a1=abs(a);
a1=1/a1;p=a1*length(n)-(a1-1)
n2=[a1*l:1:a1*u];
xn2=zeros(1,p);
j=1;
for i=1:a1:p
xn2(i)=xn(j);
j=j+1;
end
if a<0
xn2=fliplr(xn2);
end
subplot(3,1,3);
stem(n2,xn2);
end
PLOT 1 : x[2n+1]
PLOT 1 :
PLOT 2: x [-0.5n 1]
PLOT 2 :
if a<0
t=fliplr(-t);
xt=f(t);
end
plot((t+k)/a,xt);
xlabel('t');ylabel('x(at+k)')
axis([-6 6 -2 2]) ;
title('Final signal');
grid on;
PLOT 1:
x(-2t ), x(t)= sin(t);
PLOT 1:
X(t) = sin(t)
X(-2t ) is plotted.
PLOT 2:
x(-0.5t + 1) , where x(t)=t;
PLOT 2: