# Error to read dat/binary file in octave as well in matlab from gnu radio

**URL:** <https://www.ruby-forum.com/t/error-to-read-dat-binary-file-in-octave-as-well-in-matlab-from-gnu-radio/233336>\
**Category:** GNU Radio\
**Created:** [December 5, 2014, 7:01am UTC](https://www.ruby-forum.com/t/error-to-read-dat-binary-file-in-octave-as-well-in-matlab-from-gnu-radio/233336 "2014-12-05T07:01:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [December 5, 2014, 7:01am UTC](https://www.ruby-forum.com/t/error-to-read-dat-binary-file-in-octave-as-well-in-matlab-from-gnu-radio/233336/1 "2014-12-05T07:01:31Z")

</div>

Hello All,

I am facing an error when i am trying to convert dat/bin(octet streams,  
binary application) into either octave or mat format.

The bin file is generated from uhd\_rx\_cfile 0r rx\_samples\_to\_file, which  
i used for capturing the transmitted and received signals. Since the  
default extension is binary file so i want to read the I&Q data from  
that either in Matlab or Octave.

I am trying the following command in octave to convert but it throws an  
error ;

addpath("/home/username/gnuradio/gr-utils/")

data\_oct = read\_complex\_binary("/home/username/datafile name")

After this second command it is throwing an error that  
read\_complex\_binary is not defined in line 1 column 12.

What i am doing wrong ?

How can i extract the information from the bin file ?

Any help is appreciated.

Alok Ranjan

---

<div class="post-metadata">

**Author:** ![alok\_ranjan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/94ad74/32.png) [@alok\_ranjan](https://www.ruby-forum.com/u/alok_ranjan)\
**Post date:** [December 5, 2014, 7:29am UTC](https://www.ruby-forum.com/t/error-to-read-dat-binary-file-in-octave-as-well-in-matlab-from-gnu-radio/233336/2 "2014-12-05T07:29:07Z")

</div>

I am not an Octave expert by any means, but I do have a solution for  
you.  
It’s pretty slow, but it does work.

filename1 = “samples.cfile”;  
fid1 = fopen (filename1, “r”);

tmpreal = fread (fid1, “float32”, 4);  
fseek(fid1, 4, ‘bof’);  
tmpimag = fread (fid1, “float32”, 4);  
DataIn = complex(tmpreal, tmpimag);

best regards,  
Ron

---

<div class="post-metadata">

**Author:** ![alok\_ranjan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/94ad74/32.png) [@alok\_ranjan](https://www.ruby-forum.com/u/alok_ranjan)\
**Post date:** [December 5, 2014, 10:57am UTC](https://www.ruby-forum.com/t/error-to-read-dat-binary-file-in-octave-as-well-in-matlab-from-gnu-radio/233336/3 "2014-12-05T10:57:14Z")

</div>

On 12/05/2014 06:59 AM, alok ranjan via USRP-users wrote:

> What i am doing wrong ?

addpath(“/home/username/gnuradio/gr-utils/octave”)

Cheers,  
M
