[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] file_sink float format

From: Eric Blossom
Subject: Re: [Discuss-gnuradio] file_sink float format
Date: Wed, 26 Jan 2005 04:48:22 -0800
User-agent: Mutt/1.5.6i

On Wed, Jan 26, 2005 at 09:12:19AM +0000, Prateek Dayal wrote:
> Hi,
> I am trying to write a float stream to a file and I am using the
> following code for that
>       dst = gr.file_sink(gr.sizeof_float,"ntsc.am")   
> and then putting it in the graph. When I read the file it displays
> some wierd characters. I think the file is in binary. Can someone
> please specify the format the floats are being stored in. I wish to
> use the floats in some other softwares like matlab

This would give you a file containing host-native single-precision
floats.  If you're on an x86 machine, this would be IEEE-754 little

> I have been trying to use hexdump but could not figure out how to
> display in float

If you want to import them into octave, or the expensive product that
starts with an "M", use this this function from

# Copyright 2001 Free Software Foundation, Inc.
# This file is part of GNU Radio
# GNU Radio is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# GNU Radio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with GNU Radio; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

function v = read_float_binary (filename, count)

  ## usage: read_float_binary (filename, [count])
  ##  open filename and return the contents, treating them as
  ##  32 bit floats

  if ((m = nargchk (1,2,nargin)))
    usage (m);

  if (nargin < 2)
    count = Inf;

  f = fopen (filename, "r");
  if (f < 0)
    v = 0;
    v = fread (f, count, "float");
    fclose (f);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]