Category: MATLAB / Octave

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

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 […]

Using P.C. Hansen’s AIRtools and ReguTools in Python using Oct2Py

For those working with real-world inverse problems, P.C. Hansen’s AIRtools and ReguTools are great ways to quickly try out inverse methods. As in general in Python and Matlab, you need to be sure that your column vector of observations “b” is actually passed into the functions as a column vector. I’ll illustrate the issue by […]

Matlab R2014a Fortran MEX on Ubuntu 14.04

Test: 0) in terminal: cp /usr/local/MATLAB/R2014a/extern/examples/refbook/* /tmp/ 1) in matlab: mex -setup FORTRAN 2) in matlab: >> mex /tmp/timestwo.F Building with ‘gfortran’. MEX completed successfully 3) in matlab: timestwo(3) ans = 6.0