×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

12-bit Binary counter matrix in matlab

12-bit Binary counter matrix in matlab

12-bit Binary counter matrix in matlab

(OP)
Hi all,  

I want to make a sort of binary counter in a matrix form to test a dac for inl. at the moment i'm using the zeros and ones function to do a 5 bit counter but i want to extend this to 12 bits(4096 codes) and if i were to continue using the zeros and ones the lsb column would have to be written out 4096 times-not very efficient!

I wonder could anyone help me?

Thanx in advance,

Damien

RE: 12-bit Binary counter matrix in matlab

This should do it


bin_array = zeros(4096,12); % the answer will  be stored in this array
bin_str = dec2bin(0:4095,12); % convert each number to a binary string
for digit = 1:12
   % pick each binary digit in turn, convert to a number and store in the matrix
   bin_array(:,digit) = str2num(bin_str(:,digit));
end


Its the fastest way of doing it that I can think of at present. I can't off-hand think how to remove the loop by vectorisation.

M

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources