3.0

3.0 | 2 ratings Rate this file 25 Downloads (last 30 days) File Size: 1.13 KB File ID: #24282

Hexadecimal to binary

by Michael Chenoweth

 

27 May 2009

converts a hexadecimal string of just about any length to the proper binary equivalent

| Watch this File

File Information
Description

this will do the easy conversion for you without any truncating or improper values. It puts it in matrix format for easier manipulation.

hex2bin('0123456789abcdef')

ans =

  Columns 1 through 18

     0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1

  Columns 19 through 36

     0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0

  Columns 37 through 54

     1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1

  Columns 55 through 64

     0 1 1 1 1 0 1 1 1 1

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
28 May 2009 James Tursa

This function has several problems, hence the low rating.

- No help included
- No first help line
- Does not do *any* argument checking
- Does not allow for uppercase hex characters
- Does not allow for arrays of character strings as input

If you pass this function some invalid text like 'garbage', it will happily give you an answer with no warning whatsoever that your input is junk. Or if you pass it an array like ['abc';'def'], it will not process the 2nd line.

14 May 2011 Edgar Vélez Marquez  
Please login to add a comment or rating.

Contact us at files@mathworks.com