discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Decoding of a transmit signal file from matlab


From: Karthik
Subject: Re: [Discuss-gnuradio] Decoding of a transmit signal file from matlab
Date: Sat, 20 Mar 2010 12:00:26 -0700

Makmur,

gnuradio and python cannot read from matlab .mat files directly. If you want to construct a signal in Matlab then you need to use the write_float_binary() function provided in gnuradio-core/src/utils/write_float_binary.m. There are other files in there in case you want a different format. You will need to modify the files a bit since they are written to work with Octave.

Another approach is to load the variables as vectors from a .mat files using the loadmat function provided in python's scipy.io library and use a vector source. For this case your code will look something like. I have loaded variables from .mat files (filter taps etc) previously, but never used them as sources so that part is something you will have test.

from gnuradio import gr
from scipy.io import loadmat

variablelist = loadmat('/path/matfile.mat')
var1 = variablelist['var1name'].tolist()

Karthik


On Sat, Mar 20, 2010 at 9:32 AM, Makmur Hidayat <address@hidden> wrote:
Hi,
 
I try to demodulate a file of a transmit signal file (from matlab). But I can not get the correct message. Therefore I need your suggestion.
 
Below is the code
 
Thanks
Makmur
 
#!/usr/bin/env python
from gnuradio import gr
from gnuradio.eng_option import eng_option
from grc_gnuradio import wxgui as grc_wxgui
from optparse import OptionParser
import wx

class coba_demod(grc_wxgui.top_block_gui):

 def __init__(self):
  grc_wxgui.top_block_gui.__init__(self, title="Demodulasi transmit signal")

  ##################################################
  # Variables
  ##################################################
  self.samp_rate = samp_rate = 32000

  ##################################################
  # Blocks
  ##################################################
  self.gr_diff_decoder_bb_0 = gr.diff_decoder_bb(5)
  self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char*1, "/home/makmur/datacoba")
  self.gr_file_source_0 = gr.file_source(gr.sizeof_char*1, "/home/makmur/transmit_signal.mat", False)
  self.gr_throttle_0 = gr.throttle(gr.sizeof_char*1, samp_rate)

  ##################################################
  # Connections
  ##################################################
  self.connect((self.gr_file_source_0, 0), (self.gr_throttle_0, 0))
  self.connect((self.gr_throttle_0, 0), (self.gr_diff_decoder_bb_0, 0))
  self.connect((self.gr_diff_decoder_bb_0, 0), (self.gr_file_sink_0, 0))

 def set_samp_rate(self, samp_rate):
  self.samp_rate = samp_rate

if __name__ == '__main__':
 parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
 (options, args) = parser.parse_args()
 tb = coba_demod()
 tb.Run(True)

 


_______________________________________________
Discuss-gnuradio mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio



reply via email to

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