Vous êtes sur la page 1sur 15

Abstract

Based on the title, Discrete and Continuous time Signal and Convolution, we will be
introduced to the Matlab commands to create a discrete and sinusoidal waveform by a specific
function and variety data. Then, we will be taught to convolute two functions.
Objective
The purpose of this task is to illustrate the properties of continuous and discrete-time
signals using Matlab software environment.
Project background
Continuous time signal is a signal that will contain a value for all real number along the
time axis. In contrast for discrete time signal which created by sampling a continuous signal.
Means that only have values at specific time with an equally interval for each times.
Convolution is a mathematical operation on two functions that will produce a third
function that has been modified by combination of those two earlier functions.

Procedures
Task 1
Two set of command was typed in the Matlab software. The output waveform was observed and
analyze.
a) Listing 1

b) Listing 2

Task 2
A set of command was written in the Matlab command window with a sampling frequency,
fundamental frequency and amplitude was given.

The same command was written on the Matlab command window but the value of amplitude,
fundamental frequency and sampling frequency was changed twice.
First

Second

Task 3
A command was written for given function with a specified intervals. The waveform of the
function was observed and analyze.
a) sinc(t) in [-10pi, 10pi] / rect(t) in [-2, 2]

Then, a command to create a discrete-time function was written with function of a^n(u(n))-u(n10)) in -20, 20]

Task 4
A command to obtain a discrete time convolution waveform was written. The waveform was
observed and analyze.

Result and Discussion


Task 1
1

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1

10

20

30

40

50

60

Coding
n=0:2:60; %describing array
y=sin(n/6); %declaration of variable to sin function
subplot(3,1,1); %located the output
stem(n,y); %display discrete data

Question 1
Explain the effect of each command in Listing 1. You may need to draw, sketch or print out
any figures graphs in your explanation?
For the first command, it was describing a group of arrayfrom 0 to 60 with an increment
of 2. The next line commanded the declaration of a variable equal to sin function. Third
command will located the output waveform by respecting to the matrix command. Last
command is about to display discrete sequence data.

Question 2
From your observation, is listing 1 generating a continuous-time or discrete-time signal?
Discrete-time signal data data will be generate because the data use command of stem.
Question 3 (coding)
n1=0:2:60; %(For the first command, it is describing a group of array from 0 to 60 with an
increment of 2)
z=sin(n1/6); %(second line command is about declaration of sin function which an array that
has been set up before as variable of the function)
subplot(3,1,1); %(by respecting to the matrix command , it will located the output waveform)
plot(n1,z); %(show that connection of plot point to be able display signal which looks like a
continuos time signal)
n2=0:10:60; %(It is describing a group of array from 0 to 60 with an increment of 2)
w=sin(n2/6); %(Is about declaration of sin function which an array that has been set up
before as variable of the function)
subplot(3,1,3); 5 %(by respecting to the matrix command , it will located the output waveform)
plot(n2,w); %(show that connection of plot point to be able display signal which looks like a
continuos time signal)
Question 4
Plot the graph obtained from the command above?

1
0.5
0
-0.5
-1

10

20

30

40

50

60

10

20

30

40

50

60

1
0.5
0
-0.5
-1

Task 2
Question 5
Plot the graph obtained from the commands in Listing 3?
plot of a cosine waveform

Amplitude

0.5

-0.5

-1

0.5

1.5

time

2.5

3.5

4.5
-3

x 10

plot of a cosine waveform

Amplitude

0.5

-0.5

-1

10

15

20
samples

25

30

35

40

Coding and explanation


Clc;
clf;
N=35; %(declaration of variable with its own value)
A=1; %(declaration of variable with its own value)
fl=1000; %(declaration of variable with its own value)
fs=8000; %(declaration of variable with its own value)
ts=1/fs; %(declaration of variable with mathematical operation)
t=[0:ts:N*ts]; %(describing a group of array with beginning, increment and ending value)
x=A*cos(2*pi*fl*t); %(declaration of variable with cos function)
figure(1);subplot(2,1,1);plot(t,x); %(located and plot the waveform)
title('plot of a cosine waveform'); %(labeling the title for the graph)
ylabel('Amplitude');xlabel('time'); %(labeling for x and y axis)
figure(1);subplot(2,1,2);stem(x); %(located and plot the waveform)
title('plot of a cosine waveform'); %(labeling the title for the graph)
ylabel('Amplitude');xlabel('samples'); %(labeling for x and y axis)

Question 6
Write a program in MATLAB with different fundamental frequency and sampling frequency?
a)
plot of a cosine waveform

1.5

Amplitude

1
0.5
0
-0.5
-1
-1.5

0.5

1.5

time

2.5

3.5

4.5
-3

x 10

plot of a cosine waveform

1.5

Amplitude

1
0.5
0
-0.5
-1
-1.5

10

15

20
samples

25

30

35

40

Coding and explanation


clc;
clf;
N=35; %(declaration of variable with its own value)
A=1.5; %(declaration of variable with its own value)
fl=1500; %(declaration of variable with its own value)
fs=8000; %(declaration of variable with its own value)
ts=1/fs; %(declaration of variable with mathematical operation)
t=[0:ts:N*ts]; %(describing a group of array with beginning, increment and ending value)
x=A*cos(2*pi*fl*t); %(declaration of variable with cos function)
figure(1);subplot(2,1,1);plot(t,x); %(located and plot the waveform)
title('plot of a cosine waveform'); %(labeling the title for the graph)
ylabel('Amplitude');xlabel('time'); %(labeling for x and y axis)
figure(1);subplot(2,1,2);stem(x); %(located and plot the waveform)
title('plot of a cosine waveform'); %(labeling the title for the graph)
ylabel('Amplitude');xlabel('samples'); %(labeling for x and y axis)

b)
plot of a cosine waveform

Amplitude

-1

-2

0.5

1.5

time

2.5

3.5

4.5
-3

x 10

plot of a cosine waveform

Amplitude

-1

-2

10

15

20
samples

25

30

35

40

Coding and explanation


clc;
clf;
N=35; %(declaration of variable with its own value)
A=2; %(declaration of variable with its own value)
fl=2000; %(declaration of variable with its own value)
fs=8000; %(declaration of variable with its own value)
ts=1/fs; %(declaration of variable with mathematical operation)
t=[0:ts:N*ts]; %(describing a group of array with beginning, increment and ending value)
x=A*cos(2*pi*fl*t); %(declaration of variable with cos function)
figure(1);subplot(2,1,1);plot(t,x); %(located and plot the waveform)
title('plot of a cosine waveform'); %(labeling the title for the graph)
ylabel('Amplitude');xlabel('time'); %(labeling for x and y axis)
figure(1);subplot(2,1,2);stem(x); %(located and plot the waveform)
title('plot of a cosine waveform'); %(labeling the title for the graph)
ylabel('Amplitude');xlabel('samples'); %(labeling for x and y axis)

Task 3
Question 7
Write the commands you used in solving the problem Special Function?
(A)

1
0.5
0
-0.5
-40

-30

-20

-10

10

20

30

40

-1.5

-1

-0.5

0.5

1.5

0.5

0
-2

t=-10*pi:0.1:10*pi; %(describing a group of first array from -10pi to 10pi with an increment
0f 0.1)
s=-2:0.1:2; %(describing a group of second array from -2 to 2 with an increment 0f 0.1)
y=sinc(t); %(declaration of variable respect with a sinc function)
z=(abs(s)<=0.5); %(declaration of variable by computing that mathematical function)
subplot(3,1,2);plot(t,y); %(located and plot the waveform)
subplot(3,1,3);plot(s,z); %(located and plot the waveform)

(B)
0.8
0.6
0.4
0.2
0
-20

-15

-10

-5

10

15

20

-15

-10

-5

10

15

20

-15

-10

-5

10

15

20

0.5

0
-20
60
40
20
0
-20

u=inline('n>0','n');
n=(-20:1:20); %(describing a group of array from -20 to 20 with an increment of 1)
a1=0.8.^n.*(u(n)-u(n-10));
a2=1.0.^n.*(u(n)-u(n-10));
a3=1.5.^n.*(u(n)-u(n-10));
subplot(3,1,1); %(located the output waveform)
stem(n,a1); %(plot a discrete time waveform
subplot(3,1,2); %(located the output waveform)
stem(n,a2); %(plot a discrete time waveform)
subplot(3,1,3) %(located the output waveform)
stem(n,a3); %(plot a discrete time waveform)
orient tall; %(prevent crowding of a subsplots)

(C)

Task 4
2

x(nT)

1.5
1
0.5
0

10

15

20

25

10

15

20

25

h(nT)

1.5
1
0.5
0

Coding
x=[0 1 1 1 1 1 1 1 1 1 1 1 1 1];
h=[1 0.5 0.25 0.125 0.0625];
y=conv(x,h);
nz=10;
ly=length(y)+nz;
xz=[x,zeros(1,ly-length(x))];
hz=[h, zeros(1,ly-length(h))];
yz=[y, zeros(1,nz)];
nn=0:ly-1;
subplot(3,1,1),stem(nn,xz,'filled'),axis([0 25 0 2]);
ylabel('x(nT)'),grid on;
subplot(3,1,2),stem(nn,hz,'filled'),axis([0 25 0 2]);
ylabel('h(nT)'), grid on;
subplot(3,-1,3),stem(nn,yz,'filled'),axis([0 25 0 2]);
xlabel('Sample Index -n');
ylabel('y(nT)'), grid on;

Conclusion
In conclusion, we are successfully illustrated the properties of continuous and
discrete time signal using Matlab software environment after being taught the
related commands. Then we are able to differentiate the properties of discrete time

and continuous signal. Besides, we achieve to obtain a discrete time convolution


using Matlab and manually.

Vous aimerez peut-être aussi