Professional Documents
Culture Documents
Ece107l E02 14 E2
Ece107l E02 14 E2
ECE107L-E02
1. Generate the following signals and plot each one with respect to time.
a. 128 samples of sinusoid with frequency of 1000 Hz, amplitude of 0.8 and sampling rate of
8000Hz.
Syntax:
>> fs1=8000
fs =
8000
>> t=[0:127]/fs1;
>> y=0.8*sin(2*pi*2000*t);
>> plot(t, y,'c>:')
d. Compare the length 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.
Syntax:
>> fs=8000;
>> t=[0:127]/fs;
>> y=0.8*sin(2*pi*2000*t);
>> length(y)
ans =
128
fs1=1000;
>> t1=[0:(1/fs1):0.249];
>> y1=exp(-t1/0.05);
>> length(y1)
ans =
250
>> y2=[y zeros(1,122)];
>> yt=y1.*y2;
>> plot(t1,yt,'c>:')
2. a. Create and plot a sine having fundamental frequency of 75hz with 300 samples, amplitude of
2 and sampling rate of 8000hz
Sytanx:
>> fs=8000;
>> t=[0:299]/fs;
>> y=2*sin(2*pi*75*t)
>> plot(y,'c>:')
b. Add 10 harmonics to the fundamental, with amplitudes 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)*2*sin(2*pi*75*k*t);
>> k=2;y2=(1/k)*2*sin(2*pi*75*k*t);
>> k=3;y3=(1/k)*2*sin(2*pi*75*k*t);
>> k=4;y4=(1/k)*2*sin(2*pi*75*k*t);
>> k=5;y5=(1/k)*2*sin(2*pi*75*k*t);
>> k=6;y6=(1/k)*2*sin(2*pi*75*k*t);
>> k=7;y7=(1/k)*2*sin(2*pi*75*k*t);
>> k=8;y8=(1/k)*2*sin(2*pi*75*k*t);
>> k=9;y9=(1/k)*2*sin(2*pi*75*k*t);
>> k=10;y10=(1/k)*2*sin(2*pi*75*k*t);
>> k=11;y11=(1/k)*2*sin(2*pi*75*k*t);
>> ysum=y1+y2+y3+y4+y5+y6+y7+y8
+y9+y10+y11;
>> plot(ysum,'c>:')
c. Add 10 harmonics to the fundamental, with the amplitudes of 1/k where k= number of
harmonics. Plot and describe the resulting waveform.
Syntax:
>> fs=8000;
>> t=[0:299]/fs;
>> k=1;y1=(1/k)*2*sin(2*pi*75*k*t);
>> k=3;y3=(1/k)*2*sin(2*pi*75*k*t);
>> k=5;y5=(1/k)*2*sin(2*pi*75*k*t);
>> k=7;y7=(1/k)*2*sin(2*pi*75*k*t);
>> k=9;y9=(1/k)*2*sin(2*pi*75*k*t);
>> k=11;y11=(1/k)*2*sin(2*pi*75*k*t);
>> k=13;y13=(1/k)*2*sin(2*pi*75*k*t);
>> k=15;y15=(1/k)*2*sin(2*pi*75*k*t);
>> k=17;y17=(1/k)*2*sin(2*pi*75*k*t);
>> k=19;y19=(1/k)*2*sin(2*pi*75*k*t);
>> k=21;y21=(1/k)*2*sin(2*pi*75*k*t);
>> ysum=y1+y3+y5+y7+y9+y11
+y13+y15+y17+y19+y21;
>> plot(ysum,'c>:')
a. Generate the x and y coordinates using meshgrid with range from -3pi to 3pi and increment of
0.1. solve sine(R) with R=sqrt(x.^2+y.^2). Display 3D graph of sine function using plot3 command.
Syntax:
[x,y]=meshgrid((-3*pi):0.1:(3*pi));
>> R=sqrt((x.^2)+(y.^2));
>> z=(sin(R))./R;
>> plot3(x,y,z)
Description:
Syntax:
[x,y]=meshgrid((-3*pi):0.1:(3*pi));
>> R=sqrt((x.^2)+(y.^2));
>> z=(sin(R))./R;
>> contour3(x,y,z,30)
Description:
c. geberate polar coordinate (z) of complex grid using the command cplxgrid with 30 grids.
Display the complex function using cplxmap command.
i.) f(z)=(z.^5).^(1/8)
Syntax:
>> contour3(x,y,z,30)
>> z=cplxgrid(30);
>> a=(z.^5).^(1/8);
>> cplxmap(z,a)
Description:
Syntax:
z=cplxgrid(30);
>> c=atan(2*z);
>> cplxmap(z,c);
Description: