From GNU Radio
Jump to navigation Jump to search

Octave and Matlab[edit]

Octave is the most popular analysis tool with GNU Radio, as the GNU Radio package includes its own set of scripts for reading and parsing output.

Matlab is a closed source tool, and very expensive--but if you already have it installed, you might prefer it to Octave.


Installing Octave can be done from source, or in Ubuntu using:

 sudo apt-get install octave

To use the GNU Radio octave scripts, you must add the path to your Octave path variable. This is easily done using your local ~/.octaverc configuration file. If you check out the GNU Radio trunk to /home/username/gnuradio/, you can add the following to ~/.octaverc:


Parsing Data[edit]

To parse data output from GNU Radio, the easiest thing to do is use the provided scripts. Ensure that you have added the GNU Radio script path to your octave path, as described in the installing guide. These help you read data that you may have dumped to disk using gr.file_sink(size, filename).

You want to use one of the following methods, based on the size parameter used in gr.file_sink(). Each method takes a filename as the first parameter, and an optional second parameter which is the number of items to read from the file:

' _'read_complex_binary()_: gr.sizeof_gr_complex

' _'read_float_binary()_: gr.sizeof_float

' _'read_int_binary()_: gr.sizeof_int

' _'read_short_binary()_: gr.sizeof_short

' _'read_char_binary()_: gr.sizeof_char

For example, after capturing 64-bit complex using gr.file_sink(gr.sizeof_gr_complex, "capture.dat") in a Python script:


Data captured directly from the USRP is stored as 32-bit complex, rather than 64-bit complex (gr.sizeof_gr_complex). To read this data, first use read_short_binary() and then split it into a two dimensional vector:


This works for both Octave and Matlab.


To plot data using octave, it is easiest to do with gnuplot. You can install GNU plot from source or using the Ubuntu repository:

 sudo apt-get install gnuplot

To plot I and Q separately over time, graph each component separately:

 plot([real(c), imag(c)])

Generating an I/Q plot (x-axis I, y-axis Q) can be done using:


Using Python as an alternative to Octave and Matlab[edit]

Most likely you have several scientific Python libraries installed, such as SciPy and NumPy components (in particular, Matplotlib). With these tools, you can use Python to plot and analyse data.