You are on page 1of 23

Experiment 1 Generation and Operations on Signals

EXPERIMENT 1
GENERATION AND OPERATION ON SIGNALS
1.1. AIM

The objective of this experiment is to generate various types of signals such as


continuous time signals, discrete time sequences and complex exponential sequences
and operation on signals such as Aliasing, Thresholding, Folding, Shifting of the
signals etc.

1.2. SIGNAL

❖ It is variable which either carries or contains information that is to be conveyed.


❖ It is basically a record of physical Quantity.
❖ It is function of one or more independent variable.
For example: Table 1.1 shows the physical activity and the record of the
physical activity in the form of signals

Table 1.1 Records of physical activities as signals

PHYSICAL ACTIVITY RECORD


Heart ECG
Brain EEG
Muscle EMG
Eye EOG
1.2.1. CLASSIFICATION OF SIGNALS
❖ Based on number of independent variables.
➢ One-Dimensional Signal – If the signal is function of one independent
variable example f(t).
➢ Two-Dimensional Signal – If the signal is function of two independent
variable example f (x, y).
➢ Multi-Dimensional Signal – If the signal is function of more than two
independent variable example f (x, y, t).
❖ Based on nature of the Signals.
➢ Continuous time Signals or Discrete time Sequence or Digital Signals
➢ Deterministic or Random Signals
➢ Periodic or Aperiodic Signals
➢ Stationary or Non-Stationary Signals
➢ Even or Odd Signals
➢ Energy or Power Signals

1
Experiment 1 Generation and Operations on Signals

1.3. GENERATION OF CONTINUOUS TIME SIGNALS

All real-world signals are continuous in nature. They are also called as Analog Signals
The x(t) represents the continuous time signal. Continuous time signals are defined at every
instant of time i.e. for every value of independent variable there exists the value for the function
or output then it is called Continuous time signals. Independent variable is not necessarily to
be time it may be anything.

Continuous Signal to be generated in this report will be,

1.3.1. Sinusoidal Signal

1.3.2. Square Waveform

1.3.3. Sawtooth Waveform

1.3.4. Cosine Waveform

1.3.1. SINUSOIDAL SIGNAL


All real-world signals can be represented by sinusoidal functions. In mathematical
equation sinusoidal function is represented as,

x(t) = A sin (2πft +  )…………………………………….… (1.1)


Where, A → Amplitude of the signal

 → phase angle in radians.


The MATLAB code to generate the sinusoidal signal with constant amplitude frequency
and phase and corresponding output is shown in fig 1.1.

%To generate Sinusoidal Signal


clc
clear all
close all
A=5; % Amplitude
t=linspace(0,1,100); % time index
F=3; % Frequency
phase=0; % Phase
X= A*sin((2*pi*F*t)+phase);
plot(t,X),xlabel('Time'),ylabel('Amplitude'),title('Sinwave');

Fig 1.1. MATLAB code to Generate Sinusoidal Wave

2
Experiment 1 Generation and Operations on Signals

Fig 1.2. Generation of Sinusoidal Wave

The MATLAB code to generate the sinusoidal signal with constant frequency and
phase with varying Amplitude and corresponding output is shown in fig 1.2.
%To generate Sinusoidal Signal with Varying Amplitude
clc
clear all
close all
A=[5 10 15 20]; % Amplitude Vector
t=linspace(0,1,100); % time index
F=3; % Frequency; phase=0; % Phase
for i =1:length(A)
X=A(i)*sin((2*pi*F*t)+phase);
subplot(2,2,i);
plot(t,X);
xlabel('Time');
ylabel('Amplitude');
title(['Amplitude:',num2str(A(i))]);
end

Fig 1.3. MATLAB code to generate Sinusoidal Wave with Varying Amplitude

Fig 1.4. Generation of Sinusoidal Wave with Varying Amplitude.

3
Experiment 1 Generation and Operations on Signals

The MATLAB code to generate the sinusoidal signal with constant Amplitude and
phase with varying Frequency and corresponding output is shown in fig 1.3.

%To generate Sinusoidal Signal with Varying Frequency


clc
clear all
close all
F=[1 2 4 6]; % Frequency Vector
t=linspace(0,1,100); % time index A=3; % Amplitude phase=0;
for i =1:length(F)
X=A*sin((2*pi*F(i)*t)+phase);
subplot(2,2,i);plot(t,X);
xlabel('Time'),ylabel('Amplitude');
title(['Frequency:',num2str(F(i)),’Hz’]);
end

Fig 1.5. MATLAB code to generate Sinusoidal Wave with Varying Frequency

Fig 1.6. Generation of Sinusoidal Wave with Varying Frequency

The MATLAB code to generate the sinusoidal signal with constant Amplitude and
Frequency with varying Phase and corresponding output is shown in fig 1.4.

%To generate Sinusoidal Signal with Varying Phase


clc
clear all
close all
phase=[0 30 45 60]; % Phase Vector t=linspace(0,1,100);
A=3; % Amplitude F=2; % Frequency
for i =1:length(phase)
X=A*sin((2*pi*F*t)+phase(i));
subplot(2,2,i);
plot(t,X);
xlabel('Time'),ylabel('Amplitude');
title(['Phase:',num2str(phase(i)),'degree']);
end
Fig 1.7. MATLAB code to generate Sinusoidal Wave with Varying Phase

4
Experiment 1 Generation and Operations on Signals

Fig 1.8. Generation of Sinusoidal Wave with Varying Phase

INFERENCE
From Sine wave generation using MATLAB it is observed that,

1) linspace (start, end, number of sample points) built-in function is used to generate
the time index for the specified function, therefore it takes number of sample points
between start and end value. Or lese colon operator can also be used to generate the
time index.
2) Plot function is used to plot the graph between dependent and independent variables.
3) Xlabel, ylabel and title built-in functions are used to label the x-axis, y-axis and to
give title for the plot respectively.
4) Equation 1.1. is used to generate the sinusoidal wave.
5) In which amplitude A, frequency F and phase can be varied. The result is shown in
figure 1.2, 1.3, 1.4.
e2jΩ +e−2jΩ
6) Sin wave can also be generated using 2j

1.3.2. SQUARE WAVEFORM

The MATLAB code to generate the square waveform without and with MATLAB axis
built-in function figure 1.5 and 1.6 shows corresponding output waveforms.

%To generate Square Waveform without axis function


clc
clear all
close all
t=linspace(0,1,100); % time index
F=5; % Frequency
X=square(2*pi*F*t);
plot(t,X);
xlabel('Time'),ylabel('Amplitude');
title('Sqaure Wave');

Fig 1.9. MATLAB code to generate Square Wave form Without Axis Function

5
Experiment 1 Generation and Operations on Signals

%To generate Square Waveform with axis function


clc
clear all
close all
t=linspace(0,1,100); % time index
F=5; % Frequency
X=square(2*pi*F*t);
plot(t,X);
xlabel('Time'),ylabel('Amplitude');
title('Sqaure Wave');
axis([0 1 -2 2]);

Fig 1.10. MATLAB code to generate Square Wave form With Axis Function

Fig 1.11. Generation of Square waveform without Fig 1.12. Generation of Square waveform

Axis function with axis function

INFERENCE
From the Square wave generation, it is observed that
1) Square(2*pi*f*t) mathematical expression with square built-in function is used to
generate square waveform.
2) Axis ([x-limit y-limit]) built-in function is used to alter the limits of x-axis and y-axis
if axis function is not used square wave form will be seen as in figure 1.5 it is no longer
a square wave therefore when axis function is used a clear square wave form is
observed in figure 1.6.
3) Other functions are as same as the functions in sinewave generation.

6
Experiment 1 Generation and Operations on Signals

1.3.3. SAWTOOTH WAVEWORM


The MATLAB code to generate the square waveform and the corresponding
output waveform is shown in figure 1.7.

%To generate Sawtooth Waveform


clc
clear all
close all
t=linspace(0,1,100);
F=5; % Frequency
X=sawtooth(2*pi*F*t);
plot(t,X);
xlabel('Time');
ylabel('Amplitude');
title('Sawtooth Wave');

Fig 1.13. MATLAB Code to generate Sawtooth Fig 1.14. Generation of Sawtooth output
waveform Waveform

1.3.4. COSINE WAVE

The MATLAB code to generate the cosine waveform and the corresponding output
waveform is shown in figure 1.8.

%To generate Cosine Waveform


clc
clear all
close all
t=linspace(0,1,100);
F=5; % Frequency
A=5;phase=0;
X=A*cos((2*pi*F*t)+phase);
plot(t,X);
xlabel('Time'),
ylabel('Amplitude');
title('Cosine Wave');

Fig 1.15. MATLAB Code to generate Cosine Fig 1.16. Generation of Cosine output
waveform waveform

INFERENCE
From the Sawtooth and cosine waveform generation, it is observed that
1) Sawtooth (2*pi*f*t) mathematical expression with sawtooth built-in function is used
to generate sawtooth waveform.
2) Cos (2*pi*f*t) mathematical expression with cos built-in function is used to generate
cos waveform.
e2jΩ −e−2jΩ
3) Cosine wave can also be generated using 2j

7
Experiment 1 Generation and Operations on Signals

MATLAB code to generate sinhx and coshx function

% To generate Sinhx and Coshx Function


clc
clear all
close all
t=-5:0.1:5;
y1=(exp(t)-exp(-t))/2;
y2=(exp(t)+exp(-t))/2;
subplot(1,2,1),plot(t,y1),xlabel('Time');
ylabel('Amplitude'),title('Sinhx function');
subplot(1,2,2),plot(t,y2),xlabel('Time');
ylabel('Amplitude'),title('Coshx function');

Fig 1.17. MATLAB code to generate sinhx and coshx function

Fig 1.18. Sinhx and Coshx Output Waveform

INFERENCE

1) There exist built-in function for generating sinhx and coshx functions like sinh(x)
and cosh(x).
2) Such many Hyperbolic functions can also be generated using MATLAB built-in
functions.

8
Experiment 1 Generation and Operations on Signals

1.4. GENERATION OF DISCRETE TIME SEQUENCE


The discrete time signal is got by sampling the continuous time signal and the digital
signal x(nt) represents the discrete time sequence and x(n) represents the digital signal.

1.4.1 Standard DT sequences


❖ Unit sample sequence or delta sequence
❖ Unit step sequence
❖ Unit ramp sequence
❖ Complex exponential sequence

Unit sample sequence(  (n))

The functional form of unit sample sequence or delta sequence is given by,

1, n = 0
( n ) =  …………………………………………..(1.2)
0, n  0
 (n+k) is the advanced version of  (n)
 (n-k) is the delayed version of  (n)
Unit step sequence(u(n))
The functional form of unit step sequence u(n) is given by,

1, n  0
u[n] =  ……………………………………….. (1.3)
0, n  0

The significance of unit step sequence is the generation of causal signal or unilateral
signal.

Unit ramp sequence (r(n))


The functional form of unit ramp sequence is given by,

n, n  0
r[n] =  …………………………………………… (1.4)
0, n  0

Exponential sequence
The mathematical expression for the exponential sequence is given by,
x(n)=e^jΩn……………………………………………… (1.5)

where Ω=2πf and e^jΩn= cosΩn +jsinΩn

There are two types of Exponential Sequence Real and Complex.

9
Experiment 1 Generation and Operations on Signals

The MATLAB code to generate the standard DT sequences and the corresponding
plot is shown in the figures 1.9.

% to Generate the Standard Discrete time Sequences


clc
clear all
close all
n=-5:5;
x1=(n==0); % condition for Sample Sequence
x2=(n>=0); % condition for Unit step Sequence
x3=n.*(n>=0); %condition for Ramp Sequence
subplot(3,1,1),stem(n,x1,'filled');
xlabel('n'),ylabel('Amplitude');title('delta(n)');
subplot(3,1,2),stem(n,x2,'filled','r');
xlabel('n'),ylabel('Amplitude');title('u(n)');
subplot(3,1,3),stem(n,x3,'filled','g');
xlabel('n'),ylabel('Amplitude');title('r(n)');

Fig 1.19. The MATLAB code to generate the standard DT sequences

Fig 1.20 Generation of Standard Discrete time Sequence

INFERENCE
1) The unit sample sequence takes a value of one only when n=0
2) The unit step sequence takes a value of one for n=0 and n>0
3) The unit ramp sequence takes the value of n for n>0
4) Filled Built-in function is used to fill the colour at the value of x (n).
5) Stem function is used to plot the discrete time sequence signals in MATLAB.

10
Experiment 1 Generation and Operations on Signals

Task 1: Generation of unit Sample Sequence using Unit Step Sequence

% To Generate Unit Sample Sequence Using Unit Step Sequence


Clc
clear all
close all
n=-10:10;
x1=(n>=0); x2=(n>=1); y=x1-x2;
subplot(3,1,1),stem(n,x1,'Filled','r'),xlabel('n');
ylabel('Amplitude'),title('u(n)');
subplot(3,1,2),stem(n,x2,'Filled','r'),xlabel('n');
ylabel('Amplitude'),title('u(n-1)');
subplot(3,1,3),stem(n,y,'Filled','r'),xlabel('n');
ylabel('Amplitude'),title('\delta(n)');

Fig 1.21. MATLAB code to Generate unit Sample Sequence from Unit Step Sequence

Fig 1.22. Generation of unit Sample Sequence from Unit step Sequence

INFERENCE
1) Subtracting the unit step sequence with shifted unit step sequence then the resulting
discrete time signal will Unit Sample Sequence.
Task 2: Generation of unit Step Sequence using Ramp Sequence
% To Generate Unit Step Sequence Using Ramp Sequence
clc
clear all
close all
n=-10:10;
x1=(n+1).*(n>=-1);
x2=n.*(n>=0);
y=x1-x2;
subplot(3,1,1),stem(n,x1,'Filled','r'),xlabel('n');
ylabel('Amplitude');title('r(n+1)');
subplot(3,1,2),stem(n,x2,'Filled','r'),xlabel('n');
ylabel('Amplitude');title('r(n)');
subplot(3,1,3),stem(n,y,'Filled','r'),xlabel('n');
ylabel('Amplitude'); title('step(n)');
Fig 1.23. MATLAB code to Generate of unit Step Sequence from Unit Ramp Sequence

11
Experiment 1 Generation and Operations on Signals

Fig 1.24. Generation of unit Step Sequence using Ramp Sequence

INFERENCE
1) Subtracting the unit step sequence with shifted unit step sequence then the
resulting discrete time signal will Unit Sample Sequence.

The MATLAB code to generate the standard DT Exponential sequences and the
corresponding plot is shown in the figures 1.9.

% To Generate the Complex Exponential Discrete Time Sequences


clc
clear all
close all
n=-5:5;
omega=[0 pi/4 pi/2 pi];
for i=1:length(omega)
x=exp(j*omega(i)*n);
subplot(2,2,i),stem(n,x,'filled','g');
xlabel('n'),ylabel('Amplitude');
title (['Complex Exponential with omega=',num2str(omega(i))]);
end

Fig 1.25. MATLAB code to Generate Exponential Discrete Time Sequence

12
Experiment 1 Generation and Operations on Signals

Fig 1.26. Generation of Exponential Discrete time Sequence

INFERENCE
1) In Complex exponential Sequence it is observed that maximum change in frequency
will be from -1 to 1 therefore the minimum frequency will be 0 and maximum frequency
will be π.
1.5. OPERATIONS ON CONTINUOUS TIME SIGNALS

1.5.1. HEARING A SINE WAVE AS NOTE

%Hearing a sine wave as note


clc
clear all
close all
fs=1000;
t=0:1/fs:1;
f=[20 30 35 40 50 55 60 75 920 90];
for i=1
x1=sin(2*pi*f(i)*t);
x2=sin(2*pi*f(i+1)*t);
x3=sin(2*pi*f(i+2)*t);
x4=sin(2*pi*f(i+3)*t);
x5=sin(2*pi*f(i+4)*t);
x6=sin(2*pi*f(i+5)*t);
x7=sin(2*pi*f(i+6)*t);
x8=sin(2*pi*f(i+7)*t);
x9=sin(2*pi*f(i+8)*t);
x10=sin(2*pi*f(i+9)*t);
x=[x1 x2 x3 x4 x5 x6 x7 x8 x9 x10];
x2=fliplr(x);
x3=[x x2 x x2 x x2 x x2];
soundsc(x3)
end
Fig 1.27. MATLAB code to Generate Sinusoidal wave as a note

13
Experiment 1 Generation and Operations on Signals

INFERENCE
1. Soundsc built-in function is used in order to hear the sine wave as note and also to
differentiate the signals based on different frequencies.
2. And Aliasing of can also be observed Aliasing occurs When it violates Sampling theorem
i.e. fs>=2fmax.
3. Here 920Hz frequency Will be heard as 80Hz frequency because it violates the Sampling
theorem hence the heard frequency will be 1000Hz i.e. Sampling Frequency minus Signal
Frequency 1000Hz-920Hz = 80Hz.
1.5.2. THRESHOLDING
% To generate Sine Wave From Square Wave or it is to perform
Thresholding
clc
clear all
close all
A=2; F=3;
t=linspace(0,1,100);
x=A*sin(2*pi*F*t); y1=(x>=0); y2=(x<=0);
subplot(3,1,1),plot(t,x);
xlabel('time'),ylabel('Amplitude'),title('SineWave');
subplot(3,1,2),plot(t,y1);
xlabel('time'),ylabel('Amplitude'),title('Positive
Thresholding');axis([0 1 -1.5 1.5]);
subplot(3,1,3),plot(t,y2);
xlabel('time'),ylabel('Amplitude'),title('Negative
Thresholding');axis([0 1 -1.5 1.5]);

Fig 1.28. MATLAB code to perform Thresholding Operation

Fig 1.29. Generation of Thresholding output

14
Experiment 1 Generation and Operations on Signals

INFERENCE
1) condition 1: y1=(x>=0) in which the input signal above zero reference output
becomes 1 and below zero reference output becomes 0
2) condition 2: y2=(x<=0) in which the input signal above zero reference output
becomes 0 and below zero reference output becomes 1

1.5.3. FULL WAVE RECTIFIER AND HALF WAVE RECTIFIER

% To generate Sine Wave from Square Wave or it is to perform


Thresholding
clc
clear all
close all
A=2;
F=3;
t=linspace(0,1,100);
x=A*sin(2*pi*F*t);
y1=abs(x);
y2=(x+abs(x))/2;
xlabel('time'),ylabel('Amplitude'),title('SineWave');
subplot(3,1,1),plot(t,x);
xlabel('time'),ylabel('Amplitude'),title('SineWave');
subplot(3,1,2),plot(t,y1);
xlabel('time'),ylabel('Amplitude'),title('Fullwave Reectifier');
subplot(3,1,3),plot(t,y2);
xlabel('time'),ylabel('Amplitude'),title('HalfWave Rectifier');

Fig 1.30. MATLAB code to Generate Full wave and Half wave rectifier

Fig 1.31. Generation of Full-wave rectifier half wave rectifier output

15
Experiment 1 Generation and Operations on Signals

INFERENCE
1) condition 1: abs(x) built-in function gives the absolute value of output therefore the
negative half of sine wave also becomes the positive therefore full-wave rectifier is
formed
2) condition 2: (x+ abs(x))/2 gives the output of Half-wave rectifier.
1.5.4. AMPLITUDE MODULATION
%Amplitude modulation of continuous wave without using Built-in
function
clc
clear all
close all
Ac=input('enter the Carrier Wave Signal Amplitude');
Am=input('enter the Message Wave Signal Amplitude');
Fc=input('enter the Carrier Wave Signal Frequency');
Fm=input('enter the Message Wave Signal Frequency');
m=Am/Ac; t1=input('Enter the time period');
t=linspace(0,t1,1000); y1=sin(2*pi*Fm*t); y2=sin(2*pi*Fc*t);
x=((1+m.*y1).*(Ac.*y2));
subplot(3,1,1),plot(t,y1),xlabel('time'),ylabel('Amplitude');
title('Message Signal');
subplot(3,1,2),plot(t,y2),xlabel('time'),ylabel('Amplitude');
title('Carrier Signal');
subplot(3,1,3),plot(t,x),xlabel('time'),ylabel('Amplitude');
title('Modulated Signal');
Fig 1.32. MATLAB code to Perform Amplitude Modulation

Fig 1.33. Amplitude Modulation output

16
Experiment 1 Generation and Operations on Signals

1.6. OPERATIONS ON DISCRETE TIME SEQUENCE

1.6.1. FOLDING
Folding operation or time reversal is the operation of replacing the expression for time
with the negative, such that actions are reversed. The folding operation on unit ramp and unit
step sequences are done.

%Folding operation on unit step and ramp sequence


clc
clear all
close all
n=-10:10;
x1=(n>=0);
x2=(n<=0);
x3=(n).*(n>=0);
x4=(-n).*(n<=0);
subplot(2,2,1),stem(n,x1,'filled'),xlabel('n'),
ylabel('Amplitude'),title('step(n)');
subplot(2,2,2),stem(n,x2,'filled'),xlabel('n'),
ylabel('Amplitude'),title('folded step(n)');
subplot(2,2,3),stem(n,x3,'filled','r'),xlabel('n'),
ylabel('Amplitude'),title('r(n)');
subplot(2,2,4),stem(n,x4,'filled'),xlabel('n'),
ylabel('Amplitude'),title('Folded r(n)');

Fig 1.34. MATLAB code to perform Folding Operation

Fig 1.35. Folding Operation of Step and ramp Sequence

INFERENCE
1. Folding refers to reversing the axis here the axis of unit step and unit
ramp sequences are reversed.
2. Filplr() built-in function can also be used to reverse the x-axis.

17
Experiment 1 Generation and Operations on Signals

1.6.2. SHIFTING

The shifting operation on DT sequences moves the sequence either to the left
or right. The shift can be either advanced or delayed.

%Shifting operation on unit step and ramp sequence


clc
clear all
close all
n=-5:5;
x1=(n>=0); x2=n.*(n>=0); x3=(n>=2);
x4=(n>=-2);
x5=(n-2).*(n>=2);
x6=(n+2).*(n>=-2);
subplot(2,3,1),stem(n,x1,'filled'),xlabel('n'),
ylabel('Amplitude'),title('U(n)');
subplot(2,3,2),stem(n,x3,'filled'),xlabel('n'),
ylabel('Amplitude'),title('U(n-2)');
subplot(2,3,3),stem(n,x4,'filled'),xlabel('n'),
ylabel('Amplitude'),title('U(n+2)');
subplot(2,3,4),stem(n,x2,'filled','r'),xlabel('n'),
ylabel('Amplitude'),title('r(n)');
subplot(2,3,5),stem(n,x5,'filled','r'),xlabel('n'),
ylabel('Amplitude'),title('r(n-2)');
subplot(2,3,6),stem(n,x6,'filled','r'),xlabel('n'),
ylabel('Amplitude'),title('r(n+2)');

Fig 1.36. MATLAB code to perform Shifting Operation

Fig 1.37. Shifting Operation of Step and ramp Sequence

INFERENCE
Shifting means origin is shifted by the specified units either it can be
advanced or delayed here both the unit step and ramp sequences are shifted
advanced of 2 steps and delayed of 2 steps and they are implemented and plotted.

18
Experiment 1 Generation and Operations on Signals

1.6.3. SCALING

The scaling operation on DT sequences amplifies the signal amplitude


greater than one according to the constant what we specified in the code.

% Performing Scaling Operations on Discrete time Sequence


clc
clear all
close all
n=-5:5;
x1=5*(n==0);
x2=6*(n>=0);
x3=2*(n.*(n>=0));
subplot(3,1,1),stem(n,x1,'filled'),xlabel('n');
ylabel('Amplitude'),title('\delta(n)');
subplot(3,1,2),stem(n,x2,'filled','r'),xlabel('n');
ylabel('Amplitude'),title('step(n)');
subplot(3,1,3),stem(n,x3,'filled','g'),xlabel('n');
ylabel('Amplitude'),title('Ramp(n)');

Fig 1.38. MATLAB code to perform Scaling Operation on Standard Discrete time Sequence

Fig 1.39. Shifting Operation on Standard Discrete time Sequence output

INFERENCE
Scaling means Amplifying the amplitude greater than one based on our
requirement. Here Sample Sequence is amplified by the factor 5 and step sequence
is amplified by the factor 6 and Ramp sequence with amplified by 2. According to that
the Amplitude is amplified respectively.

19
Experiment 1 Generation and Operations on Signals

1.7. GENERATION AND OPERATION ON 2-D SIGNALS

Generation of 2-D points


% To Generate 2-D Unit Sample
and to move the points
clc
clear all
close all
a=zeros(256);
a(128,64)=1;
a(64,128)=1;
a(128,192)=1;
a(192,128)=1;
a(128,128)=1;
imshow(a);

Fig 1.40. MATLAB code to Generate 2-D signal Fig 1.41. Generation of 2-D signals

Taking Fast Fourier Transform for these points


Fig 1.13.
% To Generate MATLAB
2-D Unit code toand
Sample perform Thresholding
takinf fft forOperation
that points
clc
clear all
close all
a=zeros(256);
a(128,64)=1; a(64,128)=1; a(128,192)=1;
a(192,128)=1; a(128,128)=1;
A=fftshift(fft2(a));
imshow(a),figure,imshow(abs(A));

Fig 1.42. MATLAB code to perform FFT Operation on 2-D signal

Fig 1.43. 2-D points before Taking FFT Fig 1.44. 2-D points before Taking FFT

INFERENCE: The resultant picture shows they are 2-D discrete Signals therefore it
requires 2 independent variables. It is specified as row and column. If the points in 2-
D plane are taken FFT then the result will be pure white spectrum

20
Experiment 1 Generation and Operations on Signals

Taking Fast Fourier Transform for vertical line

% To Generate vertical line in 2-D plane and taking Horizontal


line
clc
clear all
close all
a=zeros(256);
a(:,128)=1;
A=fftshift(fft2(a));
imshow(a),figure,imshow(abs(A));

Fig 1.45. MATLAB code to perform FFT Operation 2-D signals

Fig 1.46. Vertical line before FFT Fig 1.47. Vertical line after FFT

INFERENCE
If the vertical line in 2-D plane are taken FFT then the result will be horizontal line in
2-D plane and vice versa

RESULT
Thus, the generation and operation on continuous signals and discrete time
sequences are observed and analysed using the various built in functions of MATLAB.

21
Experiment 1 Generation and Operations on Signals

PRE-LAB QUESTIONS

1. Define signal?
❖ It is variable which either carries or contains information that is to be conveyed.
❖ It is basically a record of physical Quantity.
❖ It is function of one or more independent variable.
2. What is the difference between continuous time signal and discrete time signal?
❖ Continuous Time Signal
It is an analog representation of a natural signal. Continuous time signals
are defined at every instant of time i.e. for every value of independent variable
there exists the value for the function or output then it is called Continuous time
signals. Independent variable is not necessarily to be time it may be anything.
❖ Discrete time Signal
The discrete time signal is got by sampling the continuous time signal and
the digital signal is got by quantizing the discrete time signal. x(nt) represents the
discrete time sequence and x(n) represents the digital signal.
3. What is the difference between analog and digital frequency?

❖ Analog Frequency

An Analog frequency have infinite resolution.


Analog waves are smooth and continuous,

❖ Digital Frequency

A Digital signal must have a finite set of possible values.


A digital frequency can only take on discrete values.
digital waves are stepping, square, and discrete.
For example, can only take on discrete values for frequency, phase,
and amplitude.
4. Write the MATLAB built-in function used to generate (i) Sine wave (ii) Square wave (iii)
Saw tooth wave and (iv) Sinc function.
a) Sin (2*pi*f*t)
b) Square (2*pi*f*t)
c) Sawtooth (2*pi*f*t)
d) Sinc (t)
5. Which variable determines the dimension of a signal?
Number of independent vairables determines the dimensions of a signal.

22
Experiment 1 Generation and Operations on Signals

6. What is the importance of axis function?

Axis function is mainly used to adjust the limits of x and y axis of the plot and
the importance of axis function is discussed with MATLAB program in section 1.3.2.

7. When the signal does have an aliasing effect?

When the Sampling frequency is less than twice the signal frequency
Aliasing effect will get into picture.
i.e. when It violates the Sampling theorem Fs = 2 Fmax
8. How unit step sequence can be generated from a unit ramp sequence?
U (n) = r (n+1) – r (n) this is the condition to generate unit step sequence
into unit ramp sequence.

9. What happens to exponential sequence when a<1 and a>1?

When a<1 the filter becomes Stable


When a>1 the filter becomes Unstable

10. Why e is called as basis function of Fourier transform?

For any value of Ω, ejΩ tells us how the system responds to an input frequency
hence Fourier transform always interrelated with frequency domain analysis i.e. the reason
why it is called basis function of Fourier transform

23

You might also like