No License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

3.3 | 4 ratings Rate this file 4 Downloads (last 30 days) File Size: 9.88 KB File ID: #4004 Version: 1.0

Call .m from Fortran



24 Sep 2003 (Updated )

This program serves as a simple example on how to interface a Fortran program to MATLAB.

| Watch this File

File Information

This heavily commented Fortran program serves as a simple example on how a MATLAB .m file can be called from Fortran. Suitable if this is your first time trying this.

The basic mechanism is to pack the C-compiled .m into a .dll and link to it from Fortran. Argument and result xfer mechanism is explained so that program can be easily expanded.

Required Products MATLAB Compiler
MATLAB release MATLAB 6.5 (R13)
Other requirements Compaq Visual Fortran Pro v6.6.0 (or similar)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
13 Apr 2014 Matt

Matt (view profile)

8"unresolved external symbol" errors dispite of the adding .lib files

Comment only
23 Mar 2008 med salah abdelouahab


Comment only
08 Nov 2007 dfa asdfa

06 May 2007 J. Miguel Marin

I have downloaded the program to call a matlab dll from Fortran CVF 6.6B.
As it did not work with MatLab v 7.2 and I saw a message from Frank Tap, I would be very grateful if anyone might tell me how to deal with this issue.
Thank you very much

Comment only
25 Jul 2006 Frank Tap

After some minor modifications it worked fine for R2006a and CVF 6.6b. Previously I tried to do it myself and stopped because it took me too much time to find it out.

18 Dec 2003 Alex Pudmenzky

Have you tried "looking into" libmx.lib with the DOS command "dumpbin/exports libmx.lib" (you can also use the "Windows Dependency Walker" available from See comments in my code. You should see all those routines supplied by MATLAB with those two tools. If they are there I don't understand why they are not linked in, if they are not there you should find a library with them in your MATLAB installation.

Comment only
18 Dec 2003 C W

Did as you said. "unresolved external symbol" errors are reduced to 5 from 8 errors. It recognize the mxCopyPtrToReal8 and a few others, but error still occurs for mxGetData,mxGetNumberOfElements,mxCreateNumericMatrix,mxClassIDFromClassName,and mxDestroyArray. Any insight?

10 Dec 2003 Alex Pudmenzky

Copy libmx.lib from your \extern\lib\win32\digital\df60\ Matlab area to "source" in your VF development area and then include libmx.lib into your project via: Project->addToProject->Files->select ".lib" from pulldown menu->select libmx.lib from "source". Same procedure for all other .lib's you may need.

Comment only
10 Dec 2003 C W

I keep having "unresolved external symbol" errors regarding to the mx* functions. I don't know how to solve this problem. I'm using the Windows 2000 and Visual Fortran 6.6.

Contact us