Tutorial on using NR3 code from within MATLAB


Bill Press
02-15-2008, 05:49 PM
MATLAB and NR3 can be a powerful combination. You can have access to MATLAB's convenience, concise syntax and great graphics, and also access the raw speed of compiled C++ code and NR3's many unique algorithms.

A tutorial is at http://www.nr.com/nr3_matlab.html.

A free interface file, which substitutes for the standard nr3.h file, is at http://www.nr.com/nr3matlab.h.

Users are encouraged to post their experiences at interfacing MATLAB to NR3 (or to C++ code in general) to this forum, starting new threads for different topics.

MATLAB-callable C++ wrapper functions for NR3 routines are also welcome to be posted. (But please don't post the NR3 code, only the wrapper.)

orstats
11-05-2008, 02:03 AM
Hello:

When I compiled MyFunc from the directions found in 'Appendix: Using Microsoft Visual Studio' in the document 'Extending MATLAB with Numerical Recipes' I received the error

cannot open file 'libmx.lib,libmex.lib,libmat.lib'

Did something go wrong in configuring the MyFunc properties?

Bill Press
11-05-2008, 03:45 PM
These library files are part of your MATLAB installation. They come in various flavors, and you have to teach your compiler (or linker, actually) how to find them. This is sometimes done by setting an environment variable like LIB, sometimes by a command line switch like /LIBPATH, or sometimes by a GUI pull-down menu choice. It all depends on what compiler and linker configuration you are using.

For example, for use with my Microsoft Visual Studio installation, the MATLAB library files are at c:\program files\matlab\r2007b\extern\lib\win32\microsoft,
and I set this within Visual Studio with the pull-down menu Project/[program name] Properties/Configuration Properties/Linker/General/Additional Library Directories. (This was given as step 9 in the Appendix to the tutorial document, here (http://www.nr.com/nr3_matlab.html#msvs) .)

orstats
11-07-2008, 04:48 AM
I still receive the same error. :( Log from the compiler was

1>Compiling...
1>stdafx.cpp
1>Compiling...
1>Skipping... (no relevant changes detected)
1>MyFunc.cpp
1>Compiling...
1>dllmain.cpp
1>Compiling resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>Linking...
1>LINK : fatal error LNK1104: cannot open file 'libmx.lib,libmex.lib,libmat.lib'
1>Project : warning PRJ0018 : The following environment variables were not found:
1>$("C:\Documents and Settings\Me\My Documents\MATLAB")

orstats
11-09-2008, 04:08 AM
May we have the same directions for when we are in the Command Prompt environment? :(