Umal-qura university


Example: Performing operations on signals entered by user



Yüklə 0,73 Mb.
səhifə17/30
tarix23.12.2023
ölçüsü0,73 Mb.
#156716
1   ...   13   14   15   16   17   18   19   20   ...   30
Signal and Systems Manual - v2full

Example: Performing operations on signals entered by user

clear
x=input('Enter the first discrete time signal\n'); len_x=length(x);


y=input('Enter the second discrete time signal\n'); len_y=length(y);

while(len_y~=len_x)


disp('Error: Length of signals must match. Enter the 2nd signal again')
y=input(''); len_y=length(y);
end
z=x+y; subplot(3,1,1)
stem(x,'filled') title('Signal 1') xlabel('Sample number') ylabel('Signal Amplitude')

subplot(3,1,2)


stem(y,'filled') title('Signal 2') xlabel('Sample number') ylabel('Signal Amplitude')

subplot(3,1,3)


stem(z,'filled') title('Resultant Signal') xlabel('Sample number') ylabel('Signal Amplitude')





output:
Enter the first discrete time signal [3 5 1 0 2]
Enter the second discrete time signal [1 1 3 2 1]




-------------------------TASK 05--------------------------


Make two separate functions for signal addition and multiplication. The functions should take the signals as input arguments and return the resultant signal. In the main program, get the signals from user, call the functions for signal addition and multiplication, and plot the original signals as well as the resultant signals.


-------------------------TASK 06--------------------------


Given the signals:
X1[n] = 2δ[n] + 5δ[n‐1] + 8δ[n‐2] + 4δ[n‐3] + 3δ[n‐4] X2[n] = δ[n‐4] + 4δ[n‐5] +3δ[n‐6] + 2δ[n‐7]
Write a Matlab program that adds these two signals. Plot the original signals as well as the final result.


-------------------------TASK 07--------------------------


Take a discrete‐time signal from user. Count the number of samples with amplitude greater than a threshold of 3 and less than a threshold of ‐3 (use for loop).



Yüklə 0,73 Mb.

Dostları ilə paylaş:
1   ...   13   14   15   16   17   18   19   20   ...   30




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə