Category: MATLAB / Octave

Posts related to useful tips & techniques for the MATLAB software by Mathworks. GNU Octave tips & compatibility issues also discussed.

Python findpeaks

If you’re looking for a Python function that works like Matlab’s “findpeaks” checkout SciPy argrelmax. If you want to do a comparison in the same code, you can call Octave findpeaks using Oct2Py, or use the Matlab Python API in Matlab R2014b

Speed of Matlab vs. Python Numpy Numba

Here is a comparison on my Intel i7-2600 Sandy Bridge (3 year old) desktop PC. Python 3.4.2, Anaconda 2.1, iPython 2.2.0, Numpy 1.8.2 with Intel MKL import numpy as np A = np.matrix(np.random.randn(5000,5000)) B = np.matrix(np.random.randn(5000,5000)) %timeit A*B 1 loops, best of 3: 2.51 s per loop Matlab R2014b, also with Intel MKL A = […]

Sparse Matrices in Python from Matlab R2014b

First of all, you can’t pass sparse matrices, so you have to have enough RAM to hold the full matrix and probably a copy or two of it. This is more just to show how it could be done, and hope that the Mathworks will improve the passing of variables in future releases of Matlab. […]

Matlab R2014b: passing matrices to/from Python

As noted in my earlier post, this is awkward because Matlab doesn’t understand Numpy arrays. Matlab understands lists, dicts, sets, scalars, and other less frequently used classes from Python. Let’s do an example with the “clown” image included with Matlab. All commands here are executed in Matlab R2014b. First off, here are some Python packages […]

Matlab R2014b: X11 forwarding and OpenGL

The new plotting engine in Matlab R2014b has caused some hangups and reduced quality plots for people using Matlab over X11 forwarding. Consider starting Matlab this way: matlab -nosoftwareopengl figure set(gcf,’renderermode’,'manual’,'renderer’,'painters’) plot(randn(100,1)) If you can’t start Matlab with the -nosoftwareopengl open, omit that open and try plotting with the set(gcf….’painters’) line as shown above for […]

Matlab R2014b: installing the integrated OpenCV support

Initially it appears that to use OpenCV from Matlab R2014b, you will need to write your OpenCV calls in C++, using all the usual Mex stuff. This is not very convenient to me; it would be much more convenient to use the friendly syntax of Python. However the Python support in Matlab R2014b allows passing […]

Matlab 2014b Python: can only pass 1xN vectors!

Note that for Matlab 2014b, which is the first version of Matlab to have official support for Python, you can only to TO python a 1xN vector. You have to reshape the matrix into a 1xN vector when passing the matrix into Python, and reshape back to a matrix inside Python, but  I think Matlab […]

Cygwin64 HDF5 load() crash fix

Currently, Octave 3.8.1 in Cygwin64 was compiled with headers 1.8.12 but HDF5 library 1.8.13. This causes Octave to seg fault Warning! ***HDF5 library version mismatched error*** and exit. To avoid having to recompile, you can type HDF5_DISABLE_VERSION_CHECK=1 octave to startup octave you can perhaps add to your ~/.bashrc file the line: alias octave=”HDF5_DISABLE_VERSION_CHECK=1 octave -q”

Stop 3-D plot crashing on Matlab over VNC

The process below is for Matlab R2014a and earlier. R2014b and newer do not support the opengl(‘neverselect’) command   Restart Matlab, and before doing anything type: opengl(‘neverselect’) Then at plotting time: figure set(gcf,’renderermode’,'manual’,'renderer’,'painters’) slice(..) and so on

Autoscaling imagesc() plot and imshow() plots

Octave 3.8 has default axis scaling that scales x and y axes proportionally to the axes values. So if one axis values span a much wider range than the other axis, the smaller span axis gets very thin. You can simply insert the line axis(‘normal’) after imagesc() In Matplotlib 1.3, the same issue occurs, which […]