Reading mat files
Here are exemples of how to read two variables {{{lat}}} and {{{lon}}} from a mat file called "test.mat".
= Matlab up to 7.1 =
mat files created with Matlab up to version 7.1 can be read using the {{{mio}}} module part of {{{scipy.io}}}. Reading structures (and arrays of structures) is supported, elements are accessed with the same syntax as in Matlab: after reading a structure called e.g. {{{struct}}}, its {{{lat}}} element can be obtained with {{{struct.lat}}}, or {{{struct.__getattribute__('lat')}}} if the element name comes from a string.
{{{
#!python
#!/usr/bin/env python
from scipy.io import loadmat
x = loadmat('test.mat')
lon = x['lon']
lat = x['lat']
# one-liner to read a single variable
lon = loadmat('test.mat')['lon']