Professional Documents
Culture Documents
Solution:
The Fourier series expansion for a square-wave is made up of a sum of odd harmonics.
Using fourier series we can have square wave from sine wave.
Program:
f=5;
t=0:0.00001:1;
x1=sin(2*3.14*f*t);
x2=(sin(2*3.14*3*f*t))/3;
x3=(sin(2*3.14*5*f*t))/5;
x4=(sin(2*3.14*7*f*t))/7;
x5=(sin(2*3.14*9*f*t))/9;
x6=(sin(2*3.14*11*f*t))/11;
y=x1+x2+x3+x4+x5+x6;
plot(y);
title('square wave generated from sine wave');
xlabel('time in micro seconds');
ylabel('y');
1.5
0.5
-0.5
-1
-1.5
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
Question 2:-
Solution:-
Like a square wave, the triangle wave contains only odd harmonics. It is possible to
approximate a triangle wave with additive synthesis by adding odd harmonics of the
fundamental, multiplying every (4n−1)th harmonic by −1 (or changing its phase by π).
Program:
f=5;
t=0:.00001:1;
x1=sin(2*3.14*f*t);
x2=(sin(2*3.14*3*f*t))/9;
x3=(sin(2*3.14*5*f*t))/25;
x4=(sin(2*3.14*7*f*t))/49;
x5=(sin(2*3.14*9*f*t))/81;
x6=(sin(2*3.14*11*f*t))/121;
y2=(8/pi^2)*(x1-x2);
y4=(8/pi^2)*(x1-x2+x3-x4);
y6=(8/pi^2)*(x1-x2+x3-x4+x5-x6);
plot(t,y2,'b-',t,y4,'r-',t,y6,'g-');
title('triangular wave generated from sine wave');
xlabel('time in micro seconds');
ylabel('y');
triangular wave generated from sine wave
1
0.8
0.6
0.4
0.2
0
y
-0.2
-0.4
-0.6
-0.8
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
time in micro seconds
Assignment 2
a) BPSK
M=2;
x=[0:M-1];
scatterplot(pskmod(x,M));
Scatter plot
1
0.8
0.6
0.4
0.2
Quadrature
-0.2
-0.4
-0.6
-0.8
-1
-1 -0.5 0 0.5 1
In-Phase
b) QPSK
M=4;
x=[0:M-1];
scatterplot(pskmod(x,M));
Scatter plot
1
0.8
0.6
0.4
0.2
Quadrature
-0.2
-0.4
-0.6
-0.8
-1
-1 -0.5 0 0.5 1
In-Phase
c) 32-bit MPSK.
M=32;
x=[0:M-1];
scatterplot(pskmod(x,M));
Scatter plot
1
0.8
0.6
0.4
0.2
Quadrature
-0.2
-0.4
-0.6
-0.8
-1
-1 -0.5 0 0.5 1
In-Phase
2. Addition of noise in saw tooth wave
Program:
t = 0:.1:10;
x = sawtooth(t); % Create sawtooth signal.
y = awgn(x,10,'measured'); % Add white Gaussian noise.
plot(t,x,t,y) % Plot both signals.
legend('Original signal','Signal with AWGN');
1.5
Original signal
Signal with AWGN
0.5
-0.5
-1
-1.5
0 1 2 3 4 5 6 7 8 9 10