Hi All
I've written an IDL routine to read MATLAB MAT-files. I thought that
this routine may be useful to others on this list, so I've made the
code available at GitHub:
https://github.com/gordonfarquharson/idl-load-mat
The routine is by no means complete: for instance, there are several
variable types that it does not support. However, the code is written
in such a way that it should be easy to extend. Note that the routine
does not read the newer HDF5 format MAT-files (see the README file for
more information).
If you find problems with the code, please use the tools at GitHub to
let me know about it. I don't have a huge amount of time to work on
this routine, but I'll see what I can do. Also, if you do extend the
program to support a new type, it would be great if you could let me
know so that we can incorporate your improvements.
You can checkout a copy of the code using git, or f you are not git-
savvy, GitHub allows you to download the code as a compressed tar file
or as a ZIP file.
Gordon
|
|
0
|
|
|
|
Reply
|
Gordon
|
3/22/2011 11:09:28 PM |
|
On Mar 22, 4:09=A0pm, Gordon Farquharson <gordonfarquhar...@gmail.com>
wrote:
> I've written an IDL routine to read MATLAB MAT-files. I thought that
> this routine may be useful to others on this list, so I've made the
> code available at GitHub:
I've just realized that you'll need an a routine I wrote called
add_path_sep.pro. Here is the code. It should be platform independent,
but I've only tested it on a Linux machine. (Is there a better way to
do this in IDL?)
---
FUNCTION add_path_sep, dir, DEFAULT=3Ddefault
compile_opt IDL2
sep_char =3D path_sep()
IF (n_elements(dir) NE 0) THEN BEGIN
_dir =3D dir
pos =3D strpos(_dir, sep_char, /REVERSE_SEARCH)
IF (pos NE (strlen(_dir)-1)) THEN _dir +=3D sep_char
ENDIF ELSE BEGIN
IF (keyword_set(default)) && (n_elements(default) NE 0) && $
(size(default, /TYPE) EQ 7) THEN BEGIN
_dir =3D default
ENDIF ELSE BEGIN
_dir =3D ''
ENDELSE
ENDELSE
return, _dir
END
---
Also, the load_mat routine only works for MAT-files written on little-
endian machines.
Gordon
|
|
0
|
|
|
|
Reply
|
Gordon
|
3/22/2011 11:55:44 PM
|
|
On Mar 22, 4:55=A0pm, Gordon Farquharson <gordonfarquhar...@gmail.com>
wrote:
> On Mar 22, 4:09=A0pm, Gordon Farquharson <gordonfarquhar...@gmail.com>
> wrote:
>
> I've just realized that you'll need an a routine I wrote called
> add_path_sep.pro. Here is the code. It should be platform independent,
> but I've only tested it on a Linux machine. (Is there a better way to
> do this in IDL?)
Thanks to a suggestion from Jim Pendleton, I've updated the code so
that it no longer requires my add_path_sep routine. It now uses the
IDL filepath routine..
I'm now working on support for MAT-files written on big endian
machines. I have an initial version working, but want to test it a
little more before releasing it. As some stage, once I become more
comfortable with git, I'll be able to make development releases
available through GitHub, I'm still learning git at the moment.
Gordon
|
|
0
|
|
|
|
Reply
|
Gordon
|
3/25/2011 4:45:01 AM
|
|
On Mar 24, 9:45=A0pm, Gordon Farquharson <gordonfarquhar...@gmail.com>
wrote:
> I'm now working on support for MAT-files written on big endian
> machines. I have an initial version working, but want to test it a
> little more before releasing it. As some stage, once I become more
> comfortable with git, I'll be able to make development releases
> available through GitHub, I'm still learning git at the moment.
My development branch is now available on GitHub. It contains a
version of the code that supports endian swapping. With this code, one
should be able to read big-endian MAT-files (written using a big-
endian machine) on a little-endian machine (tested), and visa versa (I
am not able to test reading little-endian MAT-files on a big endian
machine).
Gordon
|
|
0
|
|
|
|
Reply
|
Gordon
|
3/25/2011 11:03:48 PM
|
|
>
>
> "Gordon Farquharson" wrote in message
> news:5abf58c3-4af0-4f05-b9da-4142ebba8d97@b13g2000prf.googlegroups.com...
>
> Hi All
>
> I've written an IDL routine to read MATLAB MAT-files. I thought that
> this routine may be useful to others on this list, so I've made the
> code available at GitHub:
>
> https://github.com/gordonfarquharson/idl-load-mat
>
> The routine is by no means complete: for instance, there are several
> variable types that it does not support. However, the code is written
> in such a way that it should be easy to extend. Note that the routine
> does not read the newer HDF5 format MAT-files (see the README file for
> more information).
>
> If you find problems with the code, please use the tools at GitHub to
> let me know about it. I don't have a huge amount of time to work on
> this routine, but I'll see what I can do. Also, if you do extend the
> program to support a new type, it would be great if you could let me
> know so that we can incorporate your improvements.
>
> You can checkout a copy of the code using git, or f you are not git-
> savvy, GitHub allows you to download the code as a compressed tar file
> or as a ZIP file.
>
> Gordon
Thanks Gordon,
I work with several Matlab folks, and this will probably turn out to be very
useful for me.
cheers,
bob
|
|
0
|
|
|
|
Reply
|
noemail8476 (227)
|
4/15/2011 6:52:46 PM
|
|
|
4 Replies
1027 Views
(page loaded in 0.086 seconds)
|