CAMARINES SUR POLYTECHNIC COLLEGES
College of Engineering and Architecture
Name: John Nicole G. Chicogo
Instructor: Engr. Jayson Ebron
FINAL PROJECT IN COMMUNICATIONS 2
1. Solve the following Problems using MATLAB.
Problem 1: Determination of Entropy
Aim: To find information and entropy of a given source
Theory:
(1.) Write definition, formulas, and units for the following:
a. Information
b. Entrophy
c. Information rate
Algorithm:
1. Enter no. of symbols
2. Input the probabilities of symbols respectively.
3. Calculate the entropy of the channel input, i.e.H(x) using the formula:
Create a Matlab program based on the algorithm stated:
Example of output:
Output:
Enter no. of elements=2
Enter probabilities=[2/3,4/5]
H(x):
0.647
CAMARINES SUR POLYTECHNIC COLLEGES
College of Engineering and Architecture
% Step 1: Input the number of symbols
num_symbols = input('Enter the number of elements: ');
% Step 2: Input the probabilities of the symbols
probabilities = input('Enter probabilities (as a vector, e.g., [1/2, 1/3, 1/6]): ');
% Validate the input probabilities
if length(probabilities) ~= num_symbols
error('Number of probabilities must match the number of elements.');
end
if abs(sum(probabilities) - 1) > 1e-6
error('The probabilities must sum to 1.');
end
% Step 3: Calculate entropy
entropy = -sum(probabilities .* log2(probabilities));
% Display the result
fprintf('H(x): %.4f\n', entropy);
Enter the number of elements: 2
Enter probabilities (as a vector, e.g., [1/2, 1/3, 1/6]): [0.8, 0.2]
H(x): 0.7219
Problem 2: Frequency Division Multiplexing
Copy the code in MATLAB to generate the graph/figure for Frequency
Multiplexed signals.
Use a different sampling frequency (Fs):
CAMARINES SUR POLYTECHNIC COLLEGES
College of Engineering and Architecture
% Set the sampling frequency
Fs = 200; % Change Fs to a different value, e.g., 200 Hz
% Time vector
t = [0:2*pi*Fs-1]/Fs;
% Signal 1: Sine wave with frequency f1
f1 = 10; % Frequency of signal 1
x1 = sin(2*pi*f1*t);
% Signal 2: Sine wave with frequency f2
f2 = 30; % Frequency of signal 2
x2 = sin(2*pi*f2*t);
CAMARINES SUR POLYTECHNIC COLLEGES
College of Engineering and Architecture
% Combine signals for FDM
z = x1 + x2;
% Perform FFT (Frequency Analysis)
z1 = fft(x1);
z2 = fft(x2);
% Magnitude of the FFT signals
z1abs = abs(z1);
z2abs = abs(z2);
% Plot Signal 1
figure;
subplot(4,1,1);
plot(t, x1);
title('Signal 1');
xlabel('Time');
ylabel('Amplitude');
% Plot Signal 2
subplot(4,1,2);
plot(t, x2);
title('Signal 2');
xlabel('Time');
ylabel('Amplitude');
% Plot Frequency Spectrum of Signal 1
subplot(4,1,3);
plot(z1abs);
title('Spectrum of Signal 1');
xlabel('Frequency');
CAMARINES SUR POLYTECHNIC COLLEGES
College of Engineering and Architecture
ylabel('Magnitude');
% Plot Frequency Spectrum of Signal 2
subplot(4,1,4);
plot(z2abs);
title('Spectrum of Signal 2');
xlabel('Frequency');
ylabel('Magnitude');
% Plot Multiplexed Signal
figure;
plot(t, z);
title('Frequency Multiplexed Signal');
xlabel('Time');
ylabel('Amplitude');
Problem 3: Use MATLAB to encode characters (ASCII).
Create a sentence (it can be your favorite quote in life, a love letter, you can
state your dream job or anything you’d like to share) No minimum number of words!
You can refer to the ASCII table below :
The code to be used can be found on MATLAB Site.
CAMARINES SUR POLYTECHNIC COLLEGES
College of Engineering and Architecture
CAMARINES SUR POLYTECHNIC COLLEGES
College of Engineering and Architecture
Problem 4: Solve the following problems on Cyclic Redundancy Checking (CRC)
CAMARINES SUR POLYTECHNIC COLLEGES
College of Engineering and Architecture
CAMARINES SUR POLYTECHNIC COLLEGES
College of Engineering and Architecture