clc;
clear;
close all;
% 12-bit stream from ID 23-51617-2
% E = 6 -> 0110
% F = 1 -> 0001
% G = 7 -> 0111
bit_stream = [0 1 1 0 0 0 0 1 0 1 1 1];
no_bits = length(bit_stream);
% Parameters
bit_rate = 4000; % 4 kbps
samples_per_bit = 500; % Samples per bit
Tb = 1 / bit_rate; % Bit duration
fs = samples_per_bit / Tb;
% Total samples
no_samples = no_bits * samples_per_bit;
% Time vector
t = (0:no_samples-1) / fs;
% Initialize signal
dig_sig = zeros(1, no_samples);
% Polar NRZ-L voltage levels
positive_voltage = 5; % Logic 1
negative_voltage = -5; % Logic 0
% Generate Polar NRZ-L signal
for i = 1:no_bits
start_index = (i-1) * samples_per_bit + 1;
end_index = i * samples_per_bit;
if bit_stream(i) == 1
dig_sig(start_index:end_index) = positive_voltage;
else
dig_sig(start_index:end_index) = negative_voltage;
end
end
% Plot
figure;
plot(t, dig_sig, 'LineWidth', 1.5);
grid on;
xlabel('Time (seconds)');
ylabel('Voltage (V)');
title('Polar NRZ-L for ID 23-51617-2 (Bit Rate = 4 kbps)');
ylim([negative_voltage-1 positive_voltage+1]);
xlim([0 no_bits/bit_rate]);
To embed this project on your website, copy the following code and paste it into your website's HTML: