Hi

I am not that coded up on UHD, but I would think that they have the same
type of file writing system as is used in the GNU Radio code. In the GNU
Radio code they use a binary file writing system. I have attached a matlab M
file that reads these types of files, the file can be found in GNU Radio
file address ~/gnuradiio/gnuradio-core/src/utils. There are a large number
of matlab M files there so just have a look for the type of stuff you want
to do.

Hope it help

Regards
Alan Jones

On 13 January 2011 07:00, Sangho Oh <sangho...@gmail.com> wrote:

> Hello,
> I am trying to use "rx_samples_to_file.cpp" in UHD to save samples
> received.
> UHD seems save samples in complex integer format in c++.
> However, it is not possible to read that format from Matlab.
> I have checked the Matlab utilities in Gnuradio, but they were not useful.
> Is that any simpler way to change the formats of the saving file so that
> Matlab can easily read?
>
> Another question is that why the saved samples are integer format? not
> float?
> Thanks for reading.
>
>
> ------------------------------------------------------------------------------------------------------------
>
>     std::vector<std::complex<short> >
> buff(dev->get_max_recv_samps_per_packet());
>     std::ofstream outfile(file.c_str(), std::ofstream::binary);
>
>     while(num_acc_samps < total_num_samps){
>         size_t num_rx_samps = dev->recv(
>             &buff.front(), buff.size(), md,
>             uhd::io_type_t::COMPLEX_INT16,
>             uhd::device::RECV_MODE_ONE_PACKET
>         );
>
>         outfile.write((const char*)&buff[0], num_rx_samps *
> sizeof(std::complex<short>));
>
>
> -- *
> *
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
>
%
% 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
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% 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_complex_binary (filename, count)

 % ## usage: read_complex_binary (filename, [count])
 % ##
 % ##  open filename and return the contents as a column vector, 
 % ##  treating them as 32 bit complex numbers
 % ##

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

  if (nargin < 2)
    count = Inf;
  end

  f = fopen (filename, 'rb');
  if (f < 0)
    v = 0;
  else
    t = fread (f, [2, count], 'float');
    fclose (f);
    v = t(1,:) + t(2,:)*i;
    [r, c] = size (v);
    v = reshape (v, c, r);
  end
%endfunction;
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to