DSP 1
DSP 1
while (length(n)~=length(x))
disp('Enter the exact range of d values ');
x = input('Enter the D values for signal (x): ');
end
disp(x);
disp(length(x));
stem(n,x)
xlabel('Time');
ylabel("Amplitude");
title('Original Signal');
switch inp
case 1
tsfac = input('Enter Time Shifting Factor: ');
stem(tsfac+n,x);
xlabel('Time');
ylabel("Amplitude");
title('Time Shifted Signal');
case 2
s = input('Enter 1 for Interpolation , 2 for Decimation: ');
switch s
case 1
L = input('Enter Interpolation Factor: ');
N = (start*L:1:stop*L);
y = zeros(1,length(N));
y(1:L:length(N)) = x ;
case 2
M = input('Enter Decimation Factor: ');
sc = n/M;
N = sc(mod(sc,1)==0);
y = x(mod(sc,1)==0);
otherwise
error('Invalid choice. Enter 1 for Interpolation or 2 for
Decimation.');
end
stem(N, y);
xlabel('Time');
ylabel('Amplitude');
title('Time Scaled Signal');
case 3
stem(-n,x);
xlabel('Time');
ylabel("Amplitude");
title('Time Reversed Signal');
case 4
afac = input('Enter Amplitude Scaling Factor: ');
stem(n,x.*afac);
xlabel('Time');
ylabel("Amplitude");
title('Amplitude Scaled Signal');
case 5
otherwise
disp('Invalid Operation');
end
n1 = [1,5,2,6,8]
n2 = [4,7,3,7,2]
n3 = n1+n2
n4 = n1.*n2
t=(-2:1:2)
subplot(4,1,1)
stem(t,n1)
xlabel('Time');
ylabel("Amplitude");
title('First Signal');
subplot(4,1,2)
stem(t,n2)
xlabel('Time');
ylabel("Amplitude");
title('Second Signal');
subplot(4,1,3)
stem(t,n3)
xlabel('Time');
ylabel("Amplitude");
title('Added Signal');
subplot(4,1,4)
stem(t,n4)
xlabel('Time');
ylabel("Amplitude");
title('Multiplied Signal');