Sei sulla pagina 1di 5

Scrpt 1

clc
% asignar por parte del usuario el valor de k1, k2, h1, h2
prompt = 'Ingresar el valor de k1';
k1=input(prompt);
prompt = 'Ingresar el valor de k2';
k2=input(prompt);
prompt = 'Ingresar el valor de h1';
h1=input(prompt);
prompt = 'Ingresar el valor de h2';
h2=input(prompt);
prompt = 'Ingresar el valor de a2 que puede ser -1 o 1';
a2=input(prompt);
prompt = 'Ingresar el valor de b2 que puede ser -1 o 1';
b2=input(prompt);
a1=randi([-1 1],1,1);
b1=randi([-1 1],1,1);

n=-5:1:5;
h3=exp(a1*(n-k1));
u1=a2*[zeros(1,5+k2), ones(1,6-k2)];
x=h3.*u1;
h4=exp(b1*(n-h1));
u2=b2*[zeros(1,5+h2), ones(1,6-h2)];
h=h4.*u2;

figure(1);
subplot(3,1,1);
stem(n,x)
title('x(t)');
xlabel('time');
ylabel('amplitude');
grid on;

subplot(3,1,2);
stem(n,h)
title('h(t)');
xlabel('time');
ylabel('amplitude');
grid on;

y=conv(x,h,'same');
subplot(3,1,3);
stem(n,y);
title('System answer y(t)');
xlabel('time');
ylabel('amplitude');
grid on;

Script 2
clc
a1=0;
k1=0;
a2=1;
k2=-2;
b1=-1;
h1=3;
b2=1;
h2=0;
n=-5:1:5;
h3=exp(a1*(n-k1));
u1=a2*[zeros(1,5+k2), ones(1,6-k2)];
x=h3.*u1;

h4=exp(b1*(n-h1));
u2=b2*[zeros(1,5+h2), ones(1,6-h2)];
h=h4.*u2;

figure(1);

subplot(3,1,1);
stem(n,x)
title('x(t)');
xlabel('time');
ylabel('amplitude');
grid on;

subplot(3,1,2);
stem(n,h)
title('h(t)');
xlabel('time');
ylabel('amplitude');
grid on;

y=conv(x,h,'same');
subplot(3,1,3);
stem(n,y);
title('System answer y(t)');
xlabel('time');
ylabel('amplitude');
grid on;

Script 3
clc
a1=1;
k1=0;
a2=-1;
k2=0;

b1=-1;
h1=0;
b2=1;
h2=0;

n=-5:1:5;
h3=exp(a1*(n-k1));
u1=a2*[zeros(1,5+k2), ones(1,6-k2)];
x=h3.*u1;

h4=exp(b1*(n-h1));
u2=b2*[zeros(1,5+h2), ones(1,6-h2)];
h=h4.*u2;

figure(1);

subplot(3,1,1);
stem(n,x)
title('x(t)');
xlabel('time');
ylabel('amplitude');
grid on;

subplot(3,1,2);
stem(n,h)
title('h(t)');
xlabel('time');
ylabel('amplitude');
grid on;

y=conv(x,h,'same');
subplot(3,1,3);
stem(n,y);
title('System answer y(t)');
xlabel('time');
ylabel('amplitude');
grid on;

Potrebbero piacerti anche