0% found this document useful (0 votes)
9 views3 pages

DSP 1

The document is a MATLAB script that allows users to perform various signal processing operations such as time shifting, time scaling (interpolation and decimation), time reversal, and amplitude scaling on a given signal. Users input the start and stop values for the signal, as well as the signal values themselves, and then choose the desired operation to manipulate the signal accordingly. The script also includes functionality to visualize the original and processed signals using stem plots.

Uploaded by

behonestfull
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)
9 views3 pages

DSP 1

The document is a MATLAB script that allows users to perform various signal processing operations such as time shifting, time scaling (interpolation and decimation), time reversal, and amplitude scaling on a given signal. Users input the start and stop values for the signal, as well as the signal values themselves, and then choose the desired operation to manipulate the signal accordingly. The script also includes functionality to visualize the original and processed signals using stem plots.

Uploaded by

behonestfull
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/ 3

% inp = input('Choose Operation: 1-Time Shifting, 2-Time Scaling, 3-Time

Reversal 4-Amplitude Scaling');


start = input('Enter Start Value: ');
stop = input('Enter Stop Value: ');
n = (start:1:stop);
disp(n)

x = input('Enter the D values for signal (x): ');

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

inp = input('Choose Operation: 1-Time Shifting, 2-Time Scaling, 3-Time


Reversal 4-Amplitude Scaling');

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

You might also like