Calling Matlab Built-in Functions from Visual Studio

Hello,
I'm trying to call Matlab built-in functions (conv, trapz) from a C++ application. I have Matlab R2008b and am using Visual Studio 2008.
I've modified my C++ project to include the Matlab header files and libraries. What do i do next?
For example, here's a piece of code where I'd call trapz next:
vector<float> fn; // do something to fill fn with floats // call matlab trapz(fn) here

 Réponse acceptée

Kaustubha Govind
Kaustubha Govind le 11 Sep 2011

0 votes

I would recommend following the MATLAB Engine API documentation and trying out a simple example to help you get started.

1 commentaire

Hai Madam, I am Preethi. I am working with VC++ and now I want to use matlab engine. I have an image,and it is partitioned into so many blocks.for processing each blocks, I want to connect matlab.But when I execute the program,it works properly for some blocks.After that matlab engine didnt works and exit my program without any error messages. Mam, I close the engine each time after processing. plz give me any solution.
Thank you.

Connectez-vous pour commenter.

Plus de réponses (2)

Omar Ahmad
Omar Ahmad le 22 Sep 2011

0 votes

Hi, I tried your advice and this is just what i need. I was able to successfully compile and run the demo code for calling the MATLAB engine from Visual C++.
However, I do have a problem when I try to integrate the same calls into my existing application. It compiles and links correctly. When I run it, I get an error about missing "icuuc24.dll". Are you familiar with this problem and have any advice on how to fix this problem?

1 commentaire

I think the DLL should exist in $matlabroot/bin/$arch, where $matlabroot is the MATLAB installation directory and $arch is either win32 or win64. Add this path to the system PATH variable.

Connectez-vous pour commenter.

Omar Ahmad
Omar Ahmad le 24 Sep 2011

0 votes

Thanks, you've correctly identified the directory.
What does it mean that I have a icuuc36.dll in that directory as opposed to a icuuc24.dll?

3 commentaires

I think the number appended to icuuc increases with every version of MATLAB. Did you compile against an older version of MATLAB by any chance?
I'm not sure about versions, but i did get my code to successfully compile, link and execute. I am able to make calls to the MATLAB engine and get results back into my C++ program.
I really appreciate your guidance and support through this process.
Hello Sir, could you provide the demo of your program, i want the same, call Matlab functions into VS C++ program.

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by