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

2 次查看(过去 30 天)
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 个评论
Stephen23
Stephen23 2015-8-31
编辑:Stephen23 2015-8-31
@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.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2015-8-31
tx_bs = [tx_bs, byte];
  3 个评论
Walter Roberson
Walter Roberson 2015-8-31
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.

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by