help-octave
[Top][All Lists]
Advanced

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

Re: How can I save struct data?


From: Daniel Heiserer
Subject: Re: How can I save struct data?
Date: Wed, 21 Apr 1999 16:54:48 +0200

Joao Cardoso wrote:
> 
> Daniel Heiserer wrote:
> >
> > Akira Nishimura wrote:
> > >
> > > I'm using Octave-2.0.13 and 2.0.14.
> 
> ...
> 
> > saving octave data as a mat-file is only supported for matlab-4 files.
> > Matlab 4 had no structs and no cells. This is supported by matlab 5
> > which's
> > binary structure is different and not published.
> >
> > They are shipping libraries with them for reading and writing these
> > files. But because of OPEN-SOURCE it makes no sense to include these.
> > Maybe you could ask the MATHWORKS for revealing it's data-strucure.
> > If somebody is interested we could try to figure out what they
> > are doing.
> 
> and if we do can we use that information?

We "probably" know how the format is.

==> see below


> 
> > We would need some m-files running on matlab and octave
> > and also some stuff to decode the binaries. That is probably not
> > a big deal.
> > Somebody interested?
> >
> > Bye daniel
> 
>                               < M A T L A B >
>                   Copyright 1984-1999 The MathWorks, Inc.
>                          Version 5.3.0.10183 (R11)
>                                 Jan 21 1999
> 
> >> a.a=1;a.b=eye(3);a.c='ello';a.d=['hello';'dolly'];a.e=[1,2,3];a.f=[1;2;3;4];
> >> a.g=a;
> >> a
> 
> a =
> 
>     a: 1
>     b: [3x3 double]
>     c: 'ello'
>     d: [2x5 char]
>     e: [1 2 3]
>     f: [4x1 double]
>     g: [1x1 struct]
> 
> >> save foo a -ASCII
> Warning: Attempt to write an unsupported data type to an ascii file.
>         a not written to file.
> >> save foo a
> 
> bash-2.01$ od -x foo.mat
> 0000000  414d 4c54 4241 3520 302e 4d20 5441 662d
> 0000020  6c69 2c65 5020 616c 6674 726f 3a6d 4120
> 0000040  504c 4148 202c 7243 6165 6574 2064 6e6f
> 0000060  203a 6557 2064 7041 2072 3132 
..............

Why so complicated?

1st) I would try to find out what they are doing for matrices.
        ==> start with SMALL matrices.
starting with real, once understood take complex than string matrices
e.g.

% look for integers
     clear;a=1:3;save tmp;ip=fopen('tmp','r'); fread(ip,..... 

% maybe they store doubles different ....
        clear;a=(1:3)+0.1;save .......

to get this information is probably not that hard.

2nd) try SMALL structs or cells.

use fread inside matlab instead of od. You have all the same options
and you can run the stuff in one code.


daniel



reply via email to

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