ct and dt operations
DESCRIPTION
signal operations- MATLAB CODETRANSCRIPT
-
OPERATIONS ON DISCRETE TIME SEQUENCES
The following matlab code performs time scaling, shifting and reversal
clc;
clear;
s=input('Enter length of sequence');
l=input('Enter lower limit');
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;
end
subplot(3,1,1);
stem(n,xn);
grid on;
xlabel(n); ylabel(x[n]);
%plot x[an+k]
a=input('Enter the scaling factor');
k=input('Enter shifting factor');
%k>0advance and k0
l=l-k;u=u-k;
n=[l:u];
end
if k1 - compression
if abs(a)~=1 && abs(a)>1
for i=1:1:length(n)
k=n(i)/a;
if k-fix(k) == 0
n1(j)=k;
xn1(j)=xn(i);
disp(k);
j=j+1;
end
end
if a
- %abs(a)
-
PLOT 1 :
PLOT 2: x [-0.5n 1]
-
PLOT 2 :
-
OPERATIONS ON CONTINOUS TIME SIGNALS
The following matlab code does time scaling and shifting on CT signals.
clc;
clear all;
close all;
%plot x(at + k)
l=input('Enter lower bound of the plot');
u=input('ENter upper bound');
syms t;
x=input('Enter the function');
f=inline(x);
disp(f);
t=[l:0.01:u];
a=input('Enter the scaling factor');
k=input('Enter the shifting factor');
xt=f(t);
subplot(3,1,1);
plot(t,xt);
;ylabel('x(t)');
axis([-2*pi 2*pi -1 1]);
title('CT signal');
grid on;
subplot(3,1,2);
plot(t+k,xt);
ylabel('x(t+k)')
axis([-2*pi 2*pi -1 1]) ;
title('Shifted signal');
grid on;
subplot(3,1,3);
- if a
-
PLOT 1:
X(t) = sin(t)
X(-2t ) is plotted.
-
PLOT 2:
x(-0.5t + 1) , where x(t)=t;
PLOT 2: