-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
NumPy Cookbook
MATLAB and its open source alternative Octave are popular mathematical applications. The scipy.io package has the
savemat function, which allows you to store NumPy arrays in a .mat file as a value of a dictionary.
Installing MATLAB or Octave is outside of the scope of this book. The Octave website has some pointers for installing: http://www.gnu.org/software/octave/download.html. Check the See Also section of this recipe, for instructions on installing SciPy, if necessary.
Once you have installed MATLAB or Octave, you need to follow the subsequent steps to store NumPy arrays:
Call savemat.
Create a NumPy array, and call savemat to store the array in a .mat file. This function has two parameters—a file name and a dictionary containing variable names and values.
a = numpy.arange(7)
scipy.io.savemat("a.mat", {"array": a})Load the .mat file.
Navigate to the directory where you created the file. Load the file, and check the array...
Change the font size
Change margin width
Change background colour