You are on page 1of 10

GUANZING, Jacob Christian P.

ECE107L/ E04

1. Generate the following signals and plt each one with respect to time
a. 128 samples of sinusoid with frequency of 2000 Hz, amplitude of 0.5 and sampling rate
is 8000 Hz.

Syntax:

>> fs=8000;

>> t = [0:127]/fs;

>> y = 0.8*sin(2*pi*2000*t);

>> subplot(3,3,6);

>> plot(t,y,'m-<')

Plot:

b. Repeat 1a with sampling frequency of 6000 Hz, 4050 Hz, and 3900 Hz.

For FS = 6000 Hz

Syntax:
>> fs=6000;

>> t = [0:127]/fs;

>> y = 0.8*sin(2*pi*2000*t);

>> subplot(3,3,6);

>> plot(t,y,'m-<')

Plot:

For FS = 4050 Hz

Syntax:

>> fs=4050;

>> t = [0:127]/fs;

>> y = 0.8*sin(2*pi*2000*t);

>> subplot(3,3,6);
>> plot(t,y,'m-<')

Plot:

For FS = 3900 Hz

Syntax:

>> fs=3900;

>> t = [0:127]/fs;

>> y = 0.8*sin(2*pi*2000*t);

>> subplot(3,3,6);

>> plot(t,y,'m-<')

Plot:
Is there a change in output wavforms? Yes, there is change in waveforms

Explain. Whenever the sample rate changes (increasing or decreasing), the graph of t
vs y changes its output. As the frequency drops, the gap between the points change.

c. 250ms of an exponentially decaying signal with a time constant of 50ms; and sampling
rate is 1000Hz.
Syntax:
>> fs2 = 1000;
>> t1=[0:(1/fs2):0.249];
>> y1=exp(-t1/0.050);
>> subplot(3,3,6);
>> plot(t1,y1,'m-.<');
Plot:
d. Compare the lengths of the signals in 1a and 1c. Perform zero padding at the end of
the signal with shorter length such that the two signals will have the same length.
Multiply the two signals. Plot and describe the resulting waveform:
The graph is the sum of the two signals. It resembles a tower rotated to the left.

Syntax:
>> fs = 8000;
>> t=[0:127]/fs;
>> y=0.8*sin(2*pi*2000*t);
>> length(y);
>> fs2=1000;
>> t1=[0:(1/fs2):0.249];
>> y1=exp(-t1/0.050);
>> length(y1);
>> y(1,250)=0;
>> y3=y.*y1;
>> subplot(3,3,6);
>> plot(t1,y3,'m-.<')

Plot:

2. a. Create and plot a sine wave having fundamental frequency of 75Hz with 300 samples,
amplitude of 2, and sampling rate of 8000Hz.
Syntax:
>> fs = 8000;
>> t=[0:299]/fs;
>> y=2*sin(2*pi*75*t);
>> subplot(3,3,6);
>> plot(t,y,'m-.<')
Plot:
b. Add 10 harmonics to the fundamental, with amplitudes of 1/k, where k = harmonic
number. Plot and describe the resulting waveform
The output looks like a triangular waveform
Syntax:
>> fs = 8000;
>> t=[0:299]/fs;
>> y=2*sin(2*pi*75*t)
>> k=1;y1=(2/k)*sin(2*pi*75*t*k);
>> k=2;y2=(1/k)*sin(2*pi*75*t*k);
>> k=1;y1=(1/k)*sin(2*pi*75*t*k);
>> k=3;y3=(1/k)*sin(2*pi*75*t*k);
>> k=4;y4=(1/k)*sin(2*pi*75*t*k);
>> k=5;y5=(1/k)*sin(2*pi*75*t*k);
>> k=6;y6=(1/k)*sin(2*pi*75*t*k);
>> k=7;y7=(1/k)*sin(2*pi*75*t*k);
>> k=8;y8=(1/k)*sin(2*pi*75*t*k);
>> k=9;y9=(1/k)*sin(2*pi*75*t*k);
>> k=10;y10=(1/k)*sin(2*pi*75*t*k);
>> k=11;y11=(1/k)*sin(2*pi*75*t*k);
>> yt=y1+y2+y3+y4+y5+y6+y7+y8+y9+y10+y11;
>> subplot(3,3,6);
>> plot(t,yt,'m-.<')

Plot:

c. Add 10 odd harmonics to the fundamental, with amplitude of 1/k, where k = harmonic
number. Plot and describe the resulting waveform
Syntax:
>> fs = 8000;
>> t=[0:299]/fs;
>> k=1;y1=(1/k)*sin(2*pi*75*t*k);
>> k=3;y3=(1/k)*sin(2*pi*75*t*k);
>> k=5;y5=(1/k)*sin(2*pi*75*t*k);
>> k=7;y7=(1/k)*sin(2*pi*75*t*k);
>> k=9;y9=(1/k)*sin(2*pi*75*t*k);
>> k=11;y11=(1/k)*sin(2*pi*75*t*k);
>> k=13;y13=(1/k)*sin(2*pi*75*t*k);
>> k=15;y15=(1/k)*sin(2*pi*75*t*k);
>> k=17;y17=(1/k)*sin(2*pi*75*t*k);
>> k=19;y19=(1/k)*sin(2*pi*75*t*k);
>> k=21;y21=(1/k)*sin(2*pi*75*t*k);
>> yt=y1+y3+y5+y7+y9+y11+y13+y15+y17+y19+y21;
>> subplot(3,3,6);
>> plot(t,yt,'m-.<')
Plot:

d. Add 10 odd harmonics to the fundamental, with amplitudes of (-1)^m /k^2 where k =
harmonic number and m=((k- 1)/2)^2. Plot and describe the resulting waveform.
The output looks like a triangular waveform.
Syntax:
>> fs = 8000;
>> t=[0:299]/fs;
>> k=1; y1=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*75*k*t));
>> k=3; y3=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*75*k*t));
>> k=5; y5=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*75*k*t));
>> k=7; y7=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*75*k*t));
>> k=9; y9=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*75*k*t));
>> k=11; y11=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*75*k*t));
>> k=13; y13=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*75*k*t));
>> k=15; y15=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*75*k*t));
>> k=17; y17=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*75*k*t));
>> k=19; y19=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*75*k*t));
>> k=21; y21=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*75*k*t));
>> yt=y1+y3+y5+y7+y9+y11+y13+y15+y17+y19+y21;
>> subplot(3,3,6);
>> plot(t,yt,'m-.<')
Plot:
3. Plot the following 3-D figures below. Save display on your respective group folder. Let your
instructor check result of 3D plotting for verification
a. Generate the x and y coordinates using meshgrid with range from -3pi to 3pi and
increment of 0.1. Solve sinc® with R = sqrt(x.^2+y.^2). Display 3D graph of sinc function
using plot3. Hint: sinc(R) = sin(R)./R
Syntax:
>> [x,y]=meshgrid(-3*pi:0.1:3*pi);
>> R=sqrt(x.^2 + y.^2);
>> z1=(sin(R))./R;
>> subplot(3,3,6);
>> plot3(x,y,z1);
Plot:

Describe the output waveform: The output waveform looks like the 3D model of a steep
mountain

b. Using same sinc(R) result in 3a, plot 3D graph using contour3 command with 30 contour
levels.
Syntax:
>> [x,y]=meshgrid(-3*pi:0.1:3*pi);
>> R=sqrt(x.^2+y.^2);
>> z=(sin(R))./R;
>> subplot(3,3,6);
>> contour3(z,30);
Plot:

Copy graph to data sheet. Describe the output waveform The output waveform looks
like a steep mountain

c. Generate polar coordinate (z) of complex grid using the command cplxgrid with 30
grids. Display the complex functions using cplxmap command.
i.) F(z) = (z.^5).^(1/8)
Syntax:
>> z=cplxgrid(30);
>> x=(z.^5).^(1/8);
>> subplot(3,3,6);
>> cplxmap(z,x);
Plot:

ii.) F(z) = tan^-1(2*z)


Syntax:
>> x=atan(2*z);
>> subplot(3,3,6);
>> cplxmap(z,x);
Plot:
Results and Discussion

Generating analog signals in MATLAB can be performed by setting the number of samples on t,
and creating the sinusoidal function and save it on a variable. The graph will show up using the command
plot (t,y). On this module, it is observed that the sinusoidal wave changes with the frequency rate.
Therefore, one of the ways that the analog signal can be manipulated is to change its frequency rate.
The last part of the module was about learning how to plot 3 dimensional functions on MATLAB using
different functions, along with using the complex map.

Conclusion and Recommendation

On the first objective, to generate analog signals in MATLAB, the graph can be simulated by first
setting up the number of samples, frequency rate, and a function, whether it is sinusoidal or
growth/decay; then plotting it using the plot(a ,b) command. The Independent variable is a, and the
dependent variable is b.

On the second objective, performing analog signal manipulation, one can manipulate the
sinusoidal function by altering the number of samples, the frequency rate, or the amplitude. The exercises
in this module were to manipulate the function using different frequency rates, and by adding the concept
of harmonics to the sine function.

On the third objective, to learn how to plot on 3-dimension, first we need the 3 dimensional
function and the plot3(a, b, c) command. The parameters of the function a, b , and c, can be an immediate
value or a function; sinusoidal, logarithmic, exponential, linear, etc.. The complex map is also available for
plotting on 3-dimension using MATLAB.

You might also like