Matlab Fortran MEX selftest

less than 1 minute read

Here is a quick test to help ensure your system is properly setup to compile Fortran MEX Matlab programs.

  1. in Matlab:
  2. in Matlab or Octave:
    mex timestwo.F

    Building with ‘gfortran’. MEX completed successfully

  3. in Matlab or Octave:

    ans = 6.0

Matlab MEX Fortran issues

mex -setup -v FORTRAN

If you get error

… Looking for folder ‘libgfortranbegin.a’ …No. Did not find installed compiler ‘gfortran’. Error using mex No supported compiler or SDK was found. For options, visit

Then select the Gfortran version suitable for your Matlab release.

Leave a comment