Question: This is in matlab. I need a function bits_to_text. I want to be able to output text so that I can read what the bits
This is in matlab. I need a function bits_to_text. I want to be able to output text so that I can read what the bits are received. Below is my text_to_bits function.
% %% function text_to_bits function [bitstream] = text_to_bits(text) % %text_to_bits This function takes in text and returns a bit stream % % This function use a number of other functions built into MatLab. hex = dec2hex(text); % Takes text and turns it into hex binary = hexToBinaryVector(hex,8); % convert hex bytes to binary numDoubleBytes = size(hex,1); % get the number of bytes in data set bitstream = binary(1,:); % variable to hold the stream of bits for i = 2:numDoubleBytes % For loop to get all bits into a single vector bitstream = cat(2,bitstream,binary(i,:)); % Add another 8 bits to stream end disp("Bitstream:"); disp(bitstream); % Optional: print out all the bits in the bitstream end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
