Be the first to rate this file! 10 Downloads (last 30 days) File Size: 5.6 MB File ID: #22955
image thumbnail

MFC calls MATLAB

by David Forstot

 

11 Feb 2009

Integrating MATLABĀ® and C++ within the Microsoft Foundation Classes (MFC) environment

| Watch this File

File Information
Description

This demo highlights two ways of integrating MATLAB functionality into a MFC application written in C++. The first way uses the MATLAB Engine, an external interface that is part of core MATLAB. The second way uses MATLAB Compiler to create a C shared library from a MATLAB function foo.m. The advantage of using MATLAB Compiler is this solution can be deployed to end users that do not have MATLAB.

A simple C++/MFC dialog was created which calls into the MATLAB function in order to add the values of two numbers. The output is returned and displayed in the dialog.

The purpose of this example is to specifically show how to integrate MATLAB in the MFC framework

Required Products MATLAB Compiler
MATLAB release MATLAB 7.7 (R2008b)
Other requirements Microsoft Visual Studio 2005 or newer
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
28 Dec 2010 Junior

Hi,
i use vc 2005 and the exe file compiles fine, but it's exe file wait mclmcrrt.dll
.

Best Regards

15 Nov 2011 Jonathan

When I am trying the application in the engine mode, the project builds but does not run. When I debug the application, it gives me an unhandled exception error. What can I do to resolve this?

17 Jan 2012 Peter

Hi,

I use VS2005 and Matlab2007b. Due to the fact that I have a different Matlab (2007b) and mcc version (4.7 MCR77) I had to recompile the m script.
Now my application returns with the following error:
"Could not initialize the library."

The size of the dll is 52k wrt the original who is 204kb.

A Win32 console application works.
(Only with the option "Start Without debuggin" else is will hang.)

Dependency walker looks ok.

Any help on the "Could not initialize the library." error?

Best regards,

Peter
 

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
engine David Forstot 12 Feb 2009 14:03:15
compiler David Forstot 12 Feb 2009 14:03:15
mfc David Forstot 12 Feb 2009 14:03:15
compiler Peter 16 Jan 2012 05:25:01
engine Peter 16 Jan 2012 05:25:02
mfc Peter 16 Jan 2012 05:25:04

Contact us at files@mathworks.com