[SciPy-user] common storage between matlab and python

Barry Wark barrywark@gmail....
Tue May 6 11:46:28 CDT 2008


Have you considered mlabwrap (a scikits project)?  It allows bridged
calls into the matlab runtime (bridging sclaars, strings, numpy
arrays, etc.; I don't remember if it bridges structs). Although it's,
in some ways, a half-way solution, it would allow the issue to remain
more transparent to matlab users at the expense of a bit of overhead
for the python users.

On Tue, May 6, 2008 at 1:42 AM, Roger Herikstad
<roger.herikstad@gmail.com> wrote:
> Hi,
>   Thanks alot! I was looking at hdf5 as an alternative, and by your
>  description I think it might suit my needs. I've been considering
>  using PyTables for a while, but never had the initiative to do so, but
>  I guess this is it... My one concern is to make this as invisible to
>  pure matlab users as possible. For the time being, we are using both
>  languages, and I was hoping there was a way for both python and matlab
>  to coexist. I'll look into it.. Thanks again!
>
>   ~ Roger
>
>
>
>  On Tue, May 6, 2008 at 2:10 PM, Albert Strasheim <fullung@gmail.com> wrote:
>  > Hello,
>  >
>  >
>  >
>  >  On Tue, May 6, 2008 at 5:26 AM, Roger Herikstad
>  >  <roger.herikstad@gmail.com> wrote:
>  >  > Hi list,
>  >  >   Does anyone know of a matlab i/o interface beyond that of
>  >  >  scipy.io.loadmat /savemat? I know these routines will handle scalars
>  >  >  and vector, but what about matlab structures? My problem is that we
>  >  >  have a substantial amount of code written in matlab that makes use of
>  >  >  matlab's object oriented programming, storing the results of various
>  >  >  calculations in objects. What I would like to do is to interface with
>  >  >  these objects in python, that is read them from disk, do some
>  >  >  calculations, and write them back in a format consistent with what the
>  >  >  matlab object expects. So, for instance for the matlab object obj, the
>  >  >  data is stored as obj.data.field1, obj.data.field2, etc. Is there a
>  >  >  way for me to read the matlab file, do something to field1 and field2,
>  >  >  in python, then store the modified fields back into the structure for
>  >  >  matlab to read? Thanks!
>  >
>  >  If you don't find a solution specific to MATLAB, I'd recommend using HDF5.
>  >
>  >  Using HDF5 allows me to move my "objects" seamlessly between MATLAB,
>  >  Python and Java.
>  >
>  >  You'll have to write a bit of MATLAB code to take a struct and inspect
>  >  it using setfield, getfield and fieldnames, and then use hdf5write to
>  >  write it to disk.
>  >
>  >  obj might be stored in the HDF5 file obj.h5, with a "data" group, and
>  >  two datasets ("field1" and "field2").
>  >
>  >  Then you can load it up in PyTables, which should give you an
>  >  interface very similar to what you have in MATLAB. I think
>  >  obj.data.field1 might just work thanks to the magic that is PyTables
>  >  (where field1 could be a returned as a NumPy array).
>  >
>  >  Hope this helps.
>  >
>  >  Cheers,
>  >
>  >  Albert
>  >  _______________________________________________
>  >  SciPy-user mailing list
>  >  SciPy-user@scipy.org
>  >  http://projects.scipy.org/mailman/listinfo/scipy-user
>  >
>  _______________________________________________
>  SciPy-user mailing list
>  SciPy-user@scipy.org
>  http://projects.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-user mailing list