Exchanging information with Matlab/Octave
Matlab and its open source alternative Octave are popular numerical programs and programming languages. Octave and Matlab have syntax very similar to Python's. In fact, you can find websites that compare their syntax (for instance, see http://wiki.scipy.org/NumPy_for_Matlab_Users).
Note
Download Octave from http://www.gnu.org/software/octave/download.html.
The Octave version used at the time of writing was 4.2.0. The scipy.io.savemat()
function saves an array in a file compliant to the Octave and Matlab format. The function accepts the name of the file and a dictionary with a name for the array and the values as parameters. Refer to the ch-11.ipynb
file in this book's code bundle:
import statsmodels.api as sm from scipy.io import savemat data_loader = sm.datasets.sunspots.load_pandas() df = data_loader.data savemat("sunspots", {"sunspots": df.values})
The preceding code stores sunspot data in a file called...