folks this code for transmitting "Hello" over matlab what is the wrong with it ?

1 view (last 30 days)
tx_msg = 'Hello'; % message to transmit
SPB = 10; % bit time in samples per bit
% transmitter %
%------tx_bs=text2bitseq(tx_msg)-------
tx_bs = [];
for c = 1:length(tx_msg)
character = tx_msg(c); % get the next character from the msg
byte = char2byte(character); % find the 8-bit ASCII
tx_bs = [byte];
end
%------tx_bs=text2bitseq(tx_msg)-------
tx_wave = bitseq2waveform(tx_bs,SPB); % change bit sequence to a waveform
% The following command is needed so that we satisfy the communication protocol.
% We will study this later in the course.
tx_wave1 = satisfy_protocol(tx_wave,SPB);
% channel %
rx_wave = txrx(tx_wave1); % transmit waveform through channel
% receiver %
rx_bs = waveform2bitseq(rx_wave,SPB); % change waveform to bit sequence
rx_msg = bitseq2text(rx_bs); % change bit sequence to text message
diagram_lab01(tx_bs,tx_wave,rx_wave,rx_bs,SPB); % generate plots
display_lab01(tx_msg,rx_msg); % display text messages
  2 Comments
Stephen23
Stephen23 on 31 Aug 2015
Edited: Stephen23 on 31 Aug 2015
@AbdElrhman Rdwan: I formatted your code properly and removed all of the empty lines. In future you can do this yourself very easily by selecting the code and then clicking the {} Code button that you will find just above the textbox.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 31 Aug 2015
tx_bs = [tx_bs, byte];
  3 Comments
Walter Roberson
Walter Roberson on 31 Aug 2015
Inside your loop you currently have
tx_bs = [byte];
that overwrites all of tx_bs with the value in byte. You want to instead add byte to the end of the vector, which you do with
tx_bs = [tx_bs, byte];
in place of your current line of code.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!