Re: IDL routine to read MATLAB MAT-files [message #75523] |
Tue, 22 March 2011 16:55  |
Gordon Farquharson
Messages: 48 Registered: December 2010
|
Member |
|
|
On Mar 22, 4:09 pm, 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=default
compile_opt IDL2
sep_char = path_sep()
IF (n_elements(dir) NE 0) THEN BEGIN
_dir = dir
pos = strpos(_dir, sep_char, /REVERSE_SEARCH)
IF (pos NE (strlen(_dir)-1)) THEN _dir += sep_char
ENDIF ELSE BEGIN
IF (keyword_set(default)) && (n_elements(default) NE 0) && $
(size(default, /TYPE) EQ 7) THEN BEGIN
_dir = default
ENDIF ELSE BEGIN
_dir = ''
ENDELSE
ENDELSE
return, _dir
END
---
Also, the load_mat routine only works for MAT-files written on little-
endian machines.
Gordon
|
|
|
Re: IDL routine to read MATLAB MAT-files [message #75607 is a reply to message #75523] |
Thu, 24 March 2011 21:45  |
Gordon Farquharson
Messages: 48 Registered: December 2010
|
Member |
|
|
On Mar 22, 4:55 pm, Gordon Farquharson <gordonfarquhar...@gmail.com>
wrote:
> On Mar 22, 4:09 pm, 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
|
|
|