You are on page 1of 14

1.

) Generate the following signals and plot each one with respect to time.
a.) 180 samples of sinusoid with frequency of 2400 Hz, amplitude of 1.6 and
sampling rate is 8000Hz.

Syntax:

fs=8000;

t=[0:179]/fs;

y=1.6*sin(2*pi*2400*t);

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

Figure 1. fs= 8000

b.) Repeat 1a with sampling frequency of 6000Hz, 5000Hz, and 3500Hz. Show

Syntax
fs=6000; fs=5000; fs=3500;

t=[0:179]/fs; t=[0:179]/fs; t=[0:179]/fs;

y=1.6*sin(2*pi*2400*t); y=1.6*sin(2*pi*2400*t); y=1.6*sin(2*pi*2400*t);

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

Figure 2. fs= 6000 Figure 3. fs= 5000

Is there a Figure 4. fs= 3500 change in output


waveforms? There is a significant change in figure 3 in terms of how the wave was
projected. As for figure 2 and 4, the figures show great similarities to figure 1 however,
there are distinct peaks that might different that makes the two figure from 1.b unique.

Explain. Frequency plays big role into the formation of the plot. It is evident that this is the
case because the only changed variable with these waveforms are their ‘Fs’ or their
frequency. It can be observed that a frequency of 5000Hz make a sinusoidal waveform for
this matter.

c.) 330ms of an exponentially decaying signal with a time constant of 80ms;


and sampling rate is 1200Hz.

Syntax

fs1=1200;

t1=[0:(1/fs1):0.329];

y1=exp(-t1/0.080);

plot(t1,y1,'m--<');

Figure 5. Decaying signal with a time constant


d.) Compare the lengths of the signals in 1a. and 1c. Perform zero-padding at
the end of the signals in with shorter length such that the two signals will have the
same length. Multiply the two signals. Plot and describe the resulting waveform.

fs=8000;
y1=exp(-t1/0.080); length(y2)

t=[0:179]/fs;
length(y) yt=y1.*y2;

y=1.6*sin(2*pi*2400*t);
length(y1) plot(t1,yt,'m--<');

fs1=1200; y2=[y zeros(1,215)];

t1=[0:(1/fs1):0.329]; length(y1)

Figure 6. Length comparison of 1.a and 1.c

Description: Figure 6 is a condensed version of the wavelengths for both 1.A and 1.C. However,
the wavelength for 1.C was needed to be manipulated since the length of the matrix will not fit if
both wavelengths of A and B are combined.

2. a.) Create and plot a sine wave having fundamental frequency of 120Hz with
330 samples, amplitude of 4 and sampling rate of 8000 Hz.

fs = 8000;

t=[0:329]/fs;

y=4*sin(2*pi*120*t);

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

Figure 7. Sine wave with frequency of 120Hz with 330


samples, amplitude of 4 and sampling rate of 8000Hz


b.) Add 10 harmonics to the fundamental, with amplitude of 1/k where k = harmonic
number.

Plot and describe the resulting waveform.

fs = 8000;

t=[0:329]/fs;

y=4*sin(2*pi*120*t);

k=1;y1=(1/k)*sin(2*pi*120*t*k);

k=2;y2=(1/k)*sin(2*pi*120*t*k);

k=3;y3=(1/k)*sin(2*pi*120*t*k);

k=4;y4=(1/k)*sin(2*pi*120*t*k);

k=5;y5=(1/k)*sin(2*pi*120*t*k);

k=6;y6=(1/k)*sin(2*pi*120*t*k);

k=7;y7=(1/k)*sin(2*pi*120*t*k);

k=8;y8=(1/k)*sin(2*pi*120*t*k);

k=9;y9=(1/k)*sin(2*pi*120*t*k);

k=10;y10=(1/k)*sin(2*pi*120*t*k);

k=11;y11=(1/k)*sin(2*pi*120*t*k);

yt=y1+y2+y3+y4+y5+y6+y7+y8+y9+y10+y11;

plot(t,yt,'m--<');
Figure 8. Output with 10 harmonics

Description: Figure 8 is an output with 10 harmonics with 120Hz with 330 samples, amplitude of 4
and sampling rate of 8000Hz. It can be observed that the number of outputs defined better the
peaks and transformed it into a sawtooth wave.

c.) Add 10 odd harmonics to the fundamental, with amplitudes of 1/k where k =
harmonic number. Plot and describe the resulting waveform.

fs = 8000;

t=[0:329]/fs;

k=1;y1=(1/k)*sin(2*pi*120*t*k);

k=3;y3=(1/k)*sin(2*pi*120*t*k);

k=5;y5=(1/k)*sin(2*pi*120*t*k);
k=7;y7=(1/k)*sin(2*pi*120*t*k);

k=9;y9=(1/k)*sin(2*pi*120*t*k);

k=11;y11=(1/k)*sin(2*pi*120*t*k);

k=13;y13=(1/k)*sin(2*pi*120*t*k);

k=15;y15=(1/k)*sin(2*pi*120*t*k);

k=17;y17=(1/k)*sin(2*pi*120*t*k);

k=19;y19=(1/k)*sin(2*pi*120*t*k);

k=21;y21=(1/k)*sin(2*pi*120*t*k);

yt=y1+y3+y5+y7+y9+y11+y13+y15+y17+y19+y21;

plot(t,yt,'m--<');

Figure 9. Output with 10 odd harmonics


Description: Figure 9 is an output with 10 harmonics with 120Hz with 330 samples, amplitude of 4
and sampling rate of 8000Hz. It can be observed that the number of outputs defined better the
peaks and transformed it into a rectangular wave.

d. Add 10 odd harmonics to the fundamental, with amplitude of (-1)m/k2


where k = harmonic number and and m = ((k-1)/2)2. Plot and describe the resulting
waveform.

fs = 8000;

t=[0:329]/fs;

k=1; y1=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*120*t*k));

k=3; y3=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*120*t*k));

k=5; y5=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*120*t*k));

k=7; y7=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*120*t*k));

k=9; y9=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*120*t*k));

k=11; y11=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*120*t*k));

k=13; y13=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*120*t*k));

k=15; y15=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*120*t*k));

k=17; y17=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*120*t*k));

k=19; y19=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*120*t*k));

k=21; y21=(2*((-1)^(((k-1)/2)^2)/(k^2))*sin(2*pi*120*t*k));

yt=y1+y3+y5+y7+y9+y11+y13+y15+y17+y19+y21;

plot(t,yt,'m--<');
Figure 10. Output with 10 odd harmonics fundamental, with
amplitude of (-1)m/k2 where k = harmonic number and m =
((k-1)/2)2.

Description: Figure 10 is an output with 10 harmonics with 120Hz with 330 samples, amplitude of
4 and sampling rate of 8000Hz. It can be observed with the new amplitude, harmonic number,
and variable m, the output became a triangular waveform.

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 -5π to 5π and
increment of 0.25. Solve sinc(R) with R= sqrt(x.^2+y.+2). Display 3D graph of sinc
function using plot3 command. Hint: sinc(R)=sin(R)./R

[x,y]=meshgrid(-5*pi:0.25:5*pi);

R=sqrt(x.^2+y.^2);
Z=(sin(R))./R;

plot3(x,y,Z);

Figure 11. 3D figure using plot 3

Description: Figure 11 is the output with -5π to 5π and increment of 0.25. Using the equation:
Solve sinc(R) with R= sqrt(x.^2+y.+2) the 3D graph was constructed. It can be noticed that the
maxima of the graph has a very steep point

b.) Using same sinc(R) result in 3a, plot 3D graph using contour3 command with 50
contour levels.

[x,y]=meshgrid(-5*pi:0.25:5*pi);

R=sqrt(x.^2+y.^2);

Z=(sin(R))./R;
contour3(Z,50);

Figure 12. 3D figure using contour3

Description: Figure 12 is the output with -5π to 5π and increment of 0.25. Using the equation:
Solve sinc(R) with R= sqrt(x.^2+y.+2) the 3D graph was constructed. It can be noticed that the
graph looks like the 3.A but the only difference is that the lines are much thicker.

c. Generate polar coordinate (z) of complex grid using the command cplxgrid with 40
grids. Display the complex functions using cplxmap command.

i.) f(z) = (z.^6) . ^(1/9)

z=cplxgrid(40);

x=(z.^6).^(1/9);
cplxmap(z,x);

Figure 13. 3D figure using cplxmap



Description: Figure 13 is the output with f(z) = (z.^6).^(1/9). It can be noticed that the figure
looks like an inverted cone with purple shadow.

ii.) f(z) = tan-1 (3*z)

z=cplxgrid(40);

x=atan(3*z);

cplxmap(z,x);
Figure 14. 3D figure using cplxmap with trigonometric function

Description: Figure 14 is the output with 40 grids and uses trigonometric function. The both ends
of the 3D figure seems like floating because of the blue shadow in it. It seems like because of
the trigonometric function, the center of the graph seems like half-way closed.

You might also like