close all;
clear all;
clc;
x=input('enter sequence -1');
y=input('enter input sequence-2');
M=length(x);
N=length(y);
subplot(2,2,1);
stem(x);
xlabel('time');
ylabel('amplitude');
title('input sequence-1');
subplot(2,2,2);
stem(y);
xlabel('time');
ylabel('amplitude');
title('input sequence-2');
if M>N
z=x+[y,zeros(1,M-N)];
a=x.*[y,zeros(1,M-N)];
else
z=[x,zeros(1,N-M)]+y;
a=[x,zeros(1,N-M)].*y;
end;
subplot(2,2,3);
stem(z);
xlabel('time');
ylabel('amplitude');
title(' Addition of input sequences");
subplot(2,2,4);
stem(a);
xlabel('time');
ylabel('amplitude');
title('multiplication of input sequences ');
Output:
sequence -1[1 4 8 6]
enter input sequence-2[1 6 8 9]
clear all;
clc;
x=input('enter sequence -1');
y=input('enter input sequence-2');
M=length(x);
N=length(y);
subplot(2,2,1);
stem(x);
xlabel('time');
ylabel('amplitude');
title('input sequence-1');
subplot(2,2,2);
stem(y);
xlabel('time');
ylabel('amplitude');
title('input sequence-2');
if M>N
z=x+[y,zeros(1,M-N)];
a=x.*[y,zeros(1,M-N)];
else
z=[x,zeros(1,N-M)]+y;
a=[x,zeros(1,N-M)].*y;
end;
subplot(2,2,3);
stem(z);
xlabel('time');
ylabel('amplitude');
title(' Addition of input sequences");
subplot(2,2,4);
stem(a);
xlabel('time');
ylabel('amplitude');
title('multiplication of input sequences ');
Output:
sequence -1[1 4 8 6]
enter input sequence-2[1 6 8 9]