5.0

5.0 | 1 rating Rate this file 144 downloads (last 30 days) File Size: 1.98 KB File ID: #18072

Converting between text strings and binary vectors

by Rick Rosson

 

19 Dec 2007 (Updated 20 Dec 2007)

Code covered by BSD License  

Functions to convert from text strings to binary vectors and back again.

Download Now | Watch this File

File Information
Description

This zip file contains two functions: STR2BIN converts an ASCII text string to a vector of binary values, and BIN2STR converts a vector of binary values back to an ASCII text string.

MATLAB release MATLAB 7.5 (R2007b)
Zip File Content  
Other Files str2bin.m,
bin2str.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
11 Apr 2008 Mohammad kh  
30 Mar 2009 Vishaka

You have introduced a lot of unnecessary conversions in your code for converting from string to vector:
This line suffices for doing the conversion:
binVec = uint8(binStr) - uint8('0');
If you want a double vector, you can just do a double(binVec).

Please login to add a comment or rating.
Updates
20 Dec 2007

Added examples to the help for each function.

Tag Activity for this File
Tag Applied By Date/Time
strings Rick Rosson 22 Oct 2008 09:39:55
convert Rick Rosson 26 Jan 2009 15:04:16
data type Rick Rosson 26 Jan 2009 15:04:38
text string Rick Rosson 26 Jan 2009 15:04:38
binary Rick Rosson 26 Jan 2009 15:04:38
text Rick Rosson 26 Jan 2009 15:04:52
utility Rick Rosson 26 Jan 2009 15:05:07
ascii Rick Rosson 26 Jan 2009 15:05:50
bits Rick Rosson 08 Apr 2009 23:11:06
bit stream Rick Rosson 08 Apr 2009 23:11:06
symbols Rick Rosson 08 Apr 2009 23:11:27
communications Rick Rosson 08 Apr 2009 23:11:27
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com