200021344_EEE4702_exp01
200021344_EEE4702_exp01
200021344_EEE4702_exp01
SADMAN ASTER
ID:200021344
SECTION:C
DEPARTMENT:EEE
Experiment no.: 01
clc;
clear all;
close all;
t = -3:1:3;
y = [zeros(1,3), ones(1,1), zeros(1,3)];
stem(t,y);
ylabel('Amplitude------>');
xlabel('(a)n ------>');
title ('Unit Impulse Signal');
ans = 8
xlabel('(b)n ---->');
title (' unit step sequence ');
3. Ramp sequence
5. Sine sequence
t=0:0.05:pi ;
y=sin(2*pi*t) ;
stem(t,y) ;
ylabel('amplitude ---->') ;
xlabel('(e)n ---->') ;
title(' sine sequence ') ;
6. Cosine sequence
t=0:0.05:pi ;
y=cos(2*pi*t) ;
stem(t,y) ;
ylabel('amplitude ---->') ;
xlabel('(f)n ---->') ;
title(' cosine sequence ') ;
B. Basic operations on discrete signals:
1. Scaling: This operation involves the multiplication of each sample in a sequence by a scalar
factor.
clc;
clear all;
close all;
x1=input('enter the scaling value value ')
x1 = 3
same.
clear all;
close all;
x = input('ENTER THE FIRST SEQUENCE: ');
subplot(3,1,1);
stem(x);
title('X');
y = input('ENTER THE SECOND SEQUENCE: ');
subplot(3,1,2);
stem(y);
title('Y');
l1 = length(x);
l2 = length(y);
l3 = l1 - l2;
if l3 > 0
y = [y, zeros(1,l3)];
elseif l3 < 0
x = [x, zeros(1,abs(l3))];
end
z = x + y;
disp(z);
3 2 1 5 4
subplot(3,1,3);
stem(z);
title('Z=X+Y');
3.Subtraction:
clc;
clear all;
close all;
subtracted sequence
disp(sub);
1 -1 2 5 3 0
clc;
clear all;
close all;
n11=input('ENTER THE LOWER BOUNDARY OF THE FIRST SEQUENCE:');
n12=input('ENTER THE UPPER BOUNDARY OF THE FIRST SEQUENCE:');
n1=-n11:n12;
x=input('ENTER THE FIRST SEQUENCE:');
n21=input('ENTER THE LOWER BOUNDARY OF THE SECOND SEQUENCE:');
n22=input('ENTER THE UPPER BOUNDARY OF THE SECOND SEQUENCE:');
n2=n21:n22;
y=input('ENTER THE SECOND SEQUENCE:');
subplot(3,1,1);
stem(n1,x);
xlabel ('time')
ylabel ('amplitude')
title('FIRST SEQUENCE') ;
axis([-4 4 -5 5]);
subplot(3,1,2);
stem(n2,y);
xlabel ('time')
ylabel ('amplitude')
title('SECOND SEQUENCE');
axis([-4 4 -5 5]);
n3 =min (min(n1) ,min( n2 ) ) : max ( max ( n1 ) , max ( n2 ) );
% finding the duration of output signal (out)
s1 =zeros(1,length (n3) );
s2 =s1;
s1 (find ( ( n3>=min( n1 ) ) & ( n3 <=max ( n1 ) )==1 ) )=x;
% signal x with the duration of output signal 'mul'
s2 (find ( ( n3>=min ( n2 ) ) & ( n3 <=max ( n2 ))==1) )=y;
% signal y with the duration of output signal 'mul'
mul=s1 .* s2;
% multiplication
disp('MULTIPLIED SEQUENCE')
disp(mul)
subplot(3,1,3)
stem(n3,mul)
xlabel ('time')
ylabel ('amplitude')
5. Shifting
clc;
clear all;
close all;
n1=input('Enter the amount to be delayed');
n2=input('Enter the amount to be advanced');
n11=input('ENTER THE LOWER BOUNDARY OF THE FIRST SEQUENCE:');
n12=input('ENTER THE UPPER BOUNDARY OF THE FIRST SEQUENCE:');
n=n11:n12;
x=input('ENTER THE SEQUENCE');
subplot(3,1,1);
stem(n,x);
title('Signal x(n)');
m=n+n1;3
y=x;
subplot(3,1,2);
stem(m,y);
title('Delayed signal x(n-n1)');
t=n-n2;
z=x;
subplot(3,1,3);
stem(t,z);
title('Advanced signal x(n+n2)');
6. FOLDING or REVERSING:
clc;
clear all;
close all;
n11=input('ENTER THE LOWER BOUNDARY OF THE FIRST SEQUENCE:');
n12=input('ENTER THE UPPER BOUNDARY OF THE FIRST SEQUENCE:');
n=n11:n12;
x=input('ENTER THE SEQUENCE');
subplot(2,1,1)
stem(n,x);
axis([-3 3 -5 5]);
title('Signal x(n)');
c=fliplr(x);
y=fliplr(-n);
disp('FOLDED SEQUENCE')
disp(c)
subplot(2,1,2);
stem(y,c);
axis([-3 3 -5 5]);
title('Reversed Signal x(-n)') ;
7. Correlation
clc;
close all;
clear all;
% two input sequences
x=input('enter input sequence')
subplot(1,2,1);
stem(x);
xlabel('n');
ylabel('x(n)');
title('input sequence');
% auto correlation of input sequence
z=xcorr(x,x);
disp('The values of z are = ');
disp(z);
subplot(1,2,2);
stem(z);
xlabel('n');
ylabel('z(n)');
title('auto correlation of input sequence');
b. Cross Correlation
This correlation function is a measure of similarity between a signal & a different one.
8.Convolution:
clc;
clear all;
close all;
x1=input('Enter the first sequence x1(n) = ');
x2=input('Enter the second sequence x2(n) = ');
L=length(x1);
M=length(x2);
N=L+M-1;
yn=conv(x1,x2);
disp('The values of yn are= ');
disp(yn);
n1=0:L-1;
subplot(311);
stem(n1,x1);
grid on;
xlabel('n1--->');
ylabel('amplitude--->');
title('First sequence');
n2=0:M-1; subplot(312);
stem(n2,x2);
grid on;
xlabel('n2--->');
ylabel('amplitude--->');
title('Second sequence');
n3=0:N-1;
subplot(313);
stem(n3,yn);
grid on;
xlabel('n3--->');
ylabel('amplitude--->');
title('Convolved output');
circular convolution:
r all;
a = input('enter the sequence x(n) = ');
b = input('enter the sequence h(n) = ');
n1=length(a);
n2=length(b);
N=max(n1,n2);
x = [a zeros(1,(N-n1))];
for i = 1:N k = i; for j = 1:n2 H(i,j)=x(k)* b(j);
k = k-1; if (k == 0) k = N;
end
end
end
y=zeros(1,N);
M=H;
for j = 1:N
for i = 1:n2
y(j)=M(i,j)+y(j);
end
end
disp('The output sequence is y(n)= ');
disp(y);
stem(y);
title('Circular Convolution');
xlabel('n');
ylabel('y(n) ');
Assignment-01
1. Give a detailed and comprehensive difference between convolution and correlation nothing
carefully their domains of application
answer:
Convolution describes the output produced when a system receives an input. Each system has its
own transfer function, which defines how it reacts to a given input. When the input is applied, every
point in the input contributes a response based on the transfer function. Convolution accounts for all
input points through summation or integration, along with the transfer function, to estimate the
resulting output.
Correlation measures how alike two signals are. It compares the signals and indicates their
similarity. When normalized, correlation values range from [-1, 1], with 1 representing complete
similarity and -1 representing complete opposition. If the signals are identical except for a time shift,
it’s called autocorrelation. If other factors differ, it's referred to as cross-correlation.
Answer:
Linear convolution is a mathematical method used to determine the output of a system that behaves
in a linear and time-invariant way, based on its input and response to a short-duration signal. In
linear convolution, the two sequences (input and response) may have different lengths, meaning
they might not have the same number of data points. As a result, the output can have more or fewer
data points than either of the input sequences. The output signal may or may not follow a repeating
pattern.
Circular convolution works similarly to linear convolution but deals with sequences that repeat in a
circular manner. It involves reversing, shifting, multiplying, and summing sequences, but since the
signals repeat, the shifting can be seen as rotating. In circular convolution, both sequences must
have the same number of data points. This results in an output that has the same number of points
as the input sequences.
Answer:
A continuous signal is one that changes smoothly over time and can have any value within a certain
range at any given moment. These signals are defined for all points in time and are typically found in
analog systems, such as sound waves or temperature variations. Continuous signals are described
using continuous-time functions.
A discrete signal, however, is only defined at specific time intervals. Rather than being present at
every moment, it only has values at certain time points, and the values between these points are
ignored. An example of a discrete signal is the result of sampling a continuous signal at regular
intervals.
A digital signal is a type of discrete signal that can only take on a limited number of values, usually
represented by binary digits (0s and 1s). While discrete signals can have any numerical value at the
sampled points, digital signals are restricted to predefined levels and are commonly used in digital
electronics and computing.
Assignments 2:
- Discrete-time signals These signals are defined only at specific time intervals rather than
continuously. They often result from sampling continuous signals, like digital sound recordings.
2. Periodic or Aperiodic Signals
- Periodic signals These signals repeat themselves after a set time interval, called the period. For
example, a sine wave repeats its pattern regularly over time.
- Aperiodic signals These signals do not repeat and have no fixed time pattern. Examples include
signals like noise or single pulse waveforms.
- Energy signals These signals have finite energy but zero average power, often occurring over a
short duration, like a pulse or a signal burst.
4. Odd or Even Signals
- Even signals A signal is even if it is symmetric around the vertical axis, meaning \( f(t) = f(-t) \). An
example is a cosine wave.
- Odd signals A signal is odd if it is antisymmetric, meaning \( f(t) = -f(-t) \). An example is a sine
wave.
- Imaginary signals These signals contain only the imaginary part of a complex signal, which is
often seen in mathematical or frequency domain representations, such as in Fourier transforms.
Discussion:
In this experiment, we explored the fundamental concepts of digital signals and their simulation in
MATLAB. We generated and plotted several basic discrete signals, such as the unit impulse
sequence, unit step sequence, ramp sequence, exponential sequence, sinusoidal sequence, and
cosine sequence, and analyzed their characteristics.
Next, we implemented coding for essential operations on discrete signals, including scaling, addition,
subtraction, multiplication, shifting, folding, convolution, and correlation. We observed how each
operation influences the signal’s behavior and properties. Below are brief explanations of each
operation: