What changes do I need to make in this code to change from NRZL into NRZI?

clear; close;
bits = [0 1 1 0 1 0 0 1 0 1 1 0 0 1 0 1]; % input bit stream
streamLen = length(bits); % length of the stream positionTime = 0.0001; % position duration
endTime = streamLen - positionTime; % required end time for given bit string
t = 0:positionTime:endTime; j = 1; % index of the signal vector, s bit = 1; % current bit
for i = 0:positionTime:endTime % if (floor(i)+1 ~= bit) % checks whether in the same bit bit = bit + 1; end;
if (bits(bit) == 0) % positive voltage for bit 0
s(j) = 1;
else % negative voltage for bit 1
s(j) = -1;
end;
j = j + 1;
end;
plot(t,s); % PLOTTING THE RESULTS axis([0 streamLen -3 3]); xlabel('Signal Element (s)'); ylabel('Voltage');
set(gca, 'XGrid', 'on'); % X-axis grid set(gca, 'XTick', [0:1:streamLen]); % adjust X-axis ticks

Answers (0)

Categories

Tags

Asked:

on 24 Oct 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!