Professional Documents
Culture Documents
clc
syms tau t alpha;
x = exp(-tau);
h = exp(-2*(t-tau));
f = x*h;
y = int(f,tau,0,t);
y = simplify(y)
4
Sistemas lineares invariantes no tempo (SLIT)
U1
• Convolução gráfica:
clear all
clc
t = -1:0.01:5;
x = exp(-t).*u(t);
fig=figure();
p=plot(t,x,’k’);
set(p,’LineWidth’,2);
ylabel(‘x(t)’)
xlabel(‘Tempo (s)’);
fig=figure();
h = exp(-2*t).*u(t);
p=plot(t,h,’k’);
set(p,’LineWidth’,2);
ylabel(‘h(t)’)
xlabel(‘Tempo (s)’);
fig=figure();
t = 0.01:0.01:5;
x = exp(-t).*u(t);
h = exp(-2*t).*u(t);
p=plot(-t,h,’k’,t,x);
set(p,’LineWidth’,2);
legend(‘h(t-\tau)’,’x(\tau)’)
xlabel(‘Tempo (s)’);
t = 0:0.01:5;
fig=figure();
y=conv(h,x);
p=plot(t,y(1:length(t)),’k’);
set(p,’LineWidth’,2);
ylabel(‘y(t)’);
xlabel(‘Tempo (s)’);
Ashutosh Rout
13 Aug 2018
clc;
close all;
%first sequence
x=input('Enter x\n');
l1=input('Enter the lower limit:\n');
u1=input('Enter the upper limit:\n');
x1=l1:1:u1;%limit of sequence x(n)
%second sequence
h=input('Enter h:\n');
l2=input('Enter the lower limit:\n');
u2=input('Enter the upper limit:\n');
h1=l2:1:u2;%limit of sequence h(n)
l=l1+l2;
u=u1+u2;
a=l:1:u;%limit of output sequence y(n)
m=length(x);%length of sequence x(n)
n=length(h);%length of sequence h(n)
X=[x,zeros(1,n)];
subplot(311)
disp('x(n) is:')
disp(x)
stem(x1,x)
xlabel('n')
ylabel('x(n)')
title('First Sequence')
grid on;
H=[h,zeros(1,m)];
subplot(312)
disp('h(n) is:')
disp(h)
stem(h1,h)
xlabel('n')
ylabel('h(n)')
title('Second Sequence')
grid on;
%CONVULATION
for i=1:n+m-1
Y(i)=0;
for j=1:m
if((i-j+1)>0)
Y(i)=Y(i)+(X(j)*H(i-j+1));
else
end
end
end
subplot(313)
disp('y(n) is:')
disp(Y)
stem(a,Y)
xlabel('n')
ylabel('y(n)')
title('Output Sequence')
grid on;
clear all
clc
syms tau t alpha;
x = exp(-tau);
h = exp(-2*(t-tau));
f = x*h;
y = int(f,tau,0,t);
y = simplify(y)
4
Sistemas lineares invariantes no tempo (SLIT)
U1
• Convolução gráfica:
clear all
clc
t = -1:0.01:5;
x = exp(-t).*u(t);
fig=figure();
p=plot(t,x,’k’);
set(p,’LineWidth’,2);
ylabel(‘x(t)’)
xlabel(‘Tempo (s)’);
fig=figure();
h = exp(-2*t).*u(t);
p=plot(t,h,’k’);
set(p,’LineWidth’,2);
ylabel(‘h(t)’)
xlabel(‘Tempo (s)’);
fig=figure();
t = 0.01:0.01:5;
x = exp(-t).*u(t);
h = exp(-2*t).*u(t);
p=plot(-t,h,’k’,t,x);
set(p,’LineWidth’,2);
legend(‘h(t-\tau)’,’x(\tau)’)
xlabel(‘Tempo (s)’);
t = 0:0.01:5;
fig=figure();
y=conv(h,x);
p=plot(t,y(1:length(t)),’k’);
set(p,’LineWidth’,2);
ylabel(‘y(t)’);
xlabel(‘Tempo (s)’);
Ashutosh Rout
13 Aug 2018
clc;
close all;
%first sequence
x=input('Enter x\n');
l1=input('Enter the lower limit:\n');
u1=input('Enter the upper limit:\n');
x1=l1:1:u1;%limit of sequence x(n)
%second sequence
h=input('Enter h:\n');
l2=input('Enter the lower limit:\n');
u2=input('Enter the upper limit:\n');
h1=l2:1:u2;%limit of sequence h(n)
l=l1+l2;
u=u1+u2;
a=l:1:u;%limit of output sequence y(n)
m=length(x);%length of sequence x(n)
n=length(h);%length of sequence h(n)
X=[x,zeros(1,n)];
subplot(311)
disp('x(n) is:')
disp(x)
stem(x1,x)
xlabel('n')
ylabel('x(n)')
title('First Sequence')
grid on;
H=[h,zeros(1,m)];
subplot(312)
disp('h(n) is:')
disp(h)
stem(h1,h)
xlabel('n')
ylabel('h(n)')
title('Second Sequence')
grid on;
%CONVULATION
for i=1:n+m-1
Y(i)=0;
for j=1:m
if((i-j+1)>0)
Y(i)=Y(i)+(X(j)*H(i-j+1));
else
end
end
end
subplot(313)
disp('y(n) is:')
disp(Y)
stem(a,Y)
xlabel('n')
ylabel('y(n)')
title('Output Sequence')
grid on;
x = input('Enter x: ');
h = input('Enter h: ') ;
Ni = length(x);
Nh = length(h);
y = zeros(1,Ni+Nh);
t = zeros(1,Nh);
for i = 1:Ni+Nh-1
if i<=Ni
t(1)= x(i);
for j = 1:Nh
y(i) = y(i) + h(j)*t(j);
end
for k = Nh:-1:2
t(k) = t(k-1);
end
else
t(1)= 0;
for j = 1:Nh
y(i) = y(i) + (h(j)*t(j));
end
for k = Nh:-1:2
t(k) = t(k-1);
end
end
end
stem(y);
clc
clear all
close all
x=input('Enter the first sequence: ');
l1=input('Enter the lower limit: ');
u1=input('Enter the upper limit: ');
x1=l1:1:u1;
h=input('Enter the second sequence: ');
l2=input('Enter the lower limit: ');
u2=input('Enter the upper limit: ');
h1=l2:1:u2;
l=l1+l2;
u=u1+u2;
n=l:1:u;
s=numel(n);
i=1;
for i=1:s
y(i)=0;
for k=1:numel(x)
if (i+1-k)<=0
y(i)=y(i)+(x(k)*0);
else if (i+1-k)>numel(h)
y(i)=y(i)+(x(k)*0);
else
y(i)=y(i)+(x(k)*h(i+1-k));
k=k+1;
end
end
end
i=i+1;
end
disp(y);
subplot(2,2,1);stem(x1,x);
title('First sequence');xlabel('n');ylabel('x(n)');
subplot(2,2,2);stem(h1,h);
title('Second Sequence');xlabel('n');ylabel('h(n)');
subplot(2,2,[3 4]);stem(n,y);
title('Convoluted sequence');xlabel('n');ylabel('y(n)');
function y=my_conv(x,h)
x2=h;
lx=length(x);
lh=length(h);
if lx>lh
x2=[x2 zeros(1,lx-lh)];
else
x=[x zeros(1,lh-lx)];
end
y=zeros(1,lx+lh-1);
x=fliplr(x);
for i=1:length(y)
if i<=length(x)
y(i)=sum(x(1,length(x)-i+1:length(x)).*x2(1,1:i));
else
j=i-length(x);
y(i)=sum(x(1,1:length(x)-j).*x2(1,j+1:length(x2)));
end
end
figure
stem(y);