[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: reading version 5 MAT files
From: |
stevenj |
Subject: |
Re: reading version 5 MAT files |
Date: |
Sun, 27 Feb 2000 21:29:12 -0500 (EST) |
Hi James,
I figured out how to handle structures when I wrote the HDF5 load/save
patch that I posted to the octave-sources list. It is quite easy (once
you figure it out); let me describe how to do it:
Suppose you are reading in a structure variable, and you want to return it
as a standard octave_value variable, "ov", to the input routines.
Suppose this structure has two fields whose names are given by the
std::string or char* variables name1 and name2 and whose values are given
by the octave_value variables val1 and val2. You would then assign ov as
follows:
Octave_map m;
m [ name1 ] = val1;
m [ name2 ] = val2;
ov = m;
Of course, fieldval can be any Octave type, including a structure. You'll
need to #include "oct-map.h", among other headers.
Let me know if you have any other questions.
Cordially,
Steven G. Johnson
PS. I think you should definitely post any patch to the octave-sources
list; JWE monitors that list anyway, and that way the patch will be
archived and available to others. In contrast, I suspect that questions
of this sort are best addressed on help-octave, which is where I am cc-ing
this response.
PPS. As far as I can tell, the prospect of multi-dimensional arrays seems
dim right now in Octave--there doesn't seem to be anyone working on it,
nor does it seem like a trivial change. I handled them in my HDF5 import
code by storing them as lists of matrices (or lists of lists of matrices,
etcetera), but this is an imperfect solution (e.g. you can't (easily) do
multi-dimensional FFTs or matrix arithmetic or visualization).
On Sat, 26 Feb 2000, James R. Van Zandt wrote:
> Octave users -
>
> I have modified the octave-2.1.28 sources to read version 5 MAT files.
> So far, it handles numeric arrays and strings, when written on either
> a big endian or a little endian machine and read on an i386 machine.
>
> 1) I would like to handle structures too. I understand how they are
> stored in a MAT file and can write code to parse them. However, I do
> not understand enough about Octave internals to build the
> corresponding structures. (None of the other file formats Octave
> reads can store a structure, so I cannot work by analogy :-) If I
> write just the parser, can someone else write the rest?
>
> 2) Most of my changes are in src/load-save.cc, but I have also touched
> several other files:
>
> src/load-save.cc
> src/oct-conf.h
> configure.in
> liboctave/data-conv.cc
> liboctave/data-conv.h
>
> I can prepare a patch. Shall I post it to this list, or email it to
> jwe directly, or what? (I don't want to do either before adding the
> structure stuff, provided someone else is willing to help.)
>
> 3) Is there any prospect of handling multidimensional arrays in
> Octave?
>
> - Jim Van Zandt
>
>
>
> -----------------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
>
> Octave's home on the web: http://www.che.wisc.edu/octave/octave.html
> How to fund new projects: http://www.che.wisc.edu/octave/funding.html
> Subscription information: http://www.che.wisc.edu/octave/archive.html
> -----------------------------------------------------------------------
>
>
-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.che.wisc.edu/octave/octave.html
How to fund new projects: http://www.che.wisc.edu/octave/funding.html
Subscription information: http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: reading version 5 MAT files,
stevenj <=