0% found this document useful (0 votes)
83 views9 pages

CT and DT Operations

The MATLAB code performs operations on discrete-time and continuous-time signals including time scaling, shifting, and reversal. For discrete-time signals, it generates a random sequence, plots the original sequence, and then performs time scaling by a factor a and shifting by a factor k. For continuous-time signals, it defines a function, plots the original signal, and then performs time scaling by a factor a and shifting by a factor k on the function. It produces plots to visualize the effect of these operations on both discrete-time and continuous-time signals.

Uploaded by

VijaySankar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views9 pages

CT and DT Operations

The MATLAB code performs operations on discrete-time and continuous-time signals including time scaling, shifting, and reversal. For discrete-time signals, it generates a random sequence, plots the original sequence, and then performs time scaling by a factor a and shifting by a factor k. For continuous-time signals, it defines a function, plots the original signal, and then performs time scaling by a factor a and shifting by a factor k on the function. It produces plots to visualize the effect of these operations on both discrete-time and continuous-time signals.

Uploaded by

VijaySankar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

OPERATIONS ON DISCRETE TIME SEQUENCES

The following matlab code performs time scaling, shifting and reversal
clc;

n=[l:u];

clear;

end

s=input('Enter length of sequence');

subplot(3,1,2);

l=input('Enter lower limit');

stem(n,xn); grid on;

u=l+s-1;

xlabel(n); ylabel(x[nk]); title(Shifted


sequence);

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);

%k>0advance and k<0delay


if k>0
l=l-k;u=u-k;
n=[l:u];
end
if k<0
l=l+abs(k);u=u+abs(k);

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 :

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<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:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy