For Programmers: Free Programming Magazines  


Home > Archive > Matlab > June 2007 > Passing an array into a function









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Passing an array into a function
Tom

2007-06-09, 10:20 pm

Hi everyone...
I'm trying to pass an array into a function that I'm calling and
the function seems to be receiving or setting all values of this
array to "1". In the calling function I generate a 240-bit sequence
and pass it into another function where I parse the bit stream and
packetize the data. For whatever reason, I'm only receiving "1's" in
the receiving function when the disp command clearly shows that I
have generated a random sequence. Below is the call to the function.
Am I passing the data incorrectly or is there something that I'm
missing? Thanks for your help.

Passing function
burstgen=0;

if(op_mode == 0)
disp('Operating Mode 0: Single - 120 bit block');
info_bits = round(rand(1,120)); % Generate random bit stream
with length = 120 bits.
%disp(info_bits);
end

if(op_mode == 1)
disp('Operating Mode 1: Continuous Random Bit Stream');
fprintf('Output bit stream will consist of %d bits\n', num_bits);
info_bits = round(rand(1,num_bits)); % Generate random bit
stream. Length determined by user.
%disp(info_bits);
end

%Generate burst based on user identified burst type

% For testing only...
input_bits = info_bits;
disp(input_bits);
num_bits = length(input_bits);

if (burst_mode == 1) % Normal burst
normal_burst = normal_burst_gen2(input_bits);

Receiving Function

tail_bits = [0 0 0];
train_seq = ones(1,22);
guard_bits = zeros(1,9);

% Define number of rows in normburstgen
num_bits = length(input_bits);
num_bursts = mod(num_bits,120);
zero_vec = zeros(num_bursts,157);
%disp(zero_vec);

% Determine if zero-padding is required
% If num_bursts = 0, no zero-padding is required.
% If num_bursts > 0, the final burst will be zero padded to
achieve the
% required GMR-2+ burst structure
disp(input_bits);
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com