CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2008
    Posts
    3

    calling Matlab from c++ program

    Hi,

    Can anyone of u help me to call Matlab functions from c++ program.

    I need to write a c++ program and from this, i need to carry out a few calculations and need to plot the graphs. I have Matlab Component Runtime. Will it enough? or need any other to do the above things.

    Thanks in advance...........

  2. #2
    Join Date
    Dec 2001
    Location
    Greece, Athens
    Posts
    1,015

    Re: calling Matlab from c++ program

    You'll need to use the Matlab add in for visual studio. Here is an example:
    http://www.codeproject.com/KB/macros...ab_add_in.aspx

    And here is the Mathworks' instructions for setting up the Matlab add-in.
    http://www.mathworks.com/support/sol...lution=1-18L04

    Theodore
    Personal Web Page (some audio segmentation tools): www.di.uoa.gr/~tyiannak

  3. #3
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: calling Matlab from c++ program

    If you have the C files spat out by the Matlab compiler, the Matlab Component Runtime will be good enough. If you don't, you'll need the full version of Matlab, in order to use the Matlab Engine.

    Note that one way is not really faster than the other. The Matlab Compiler doesn't actually generate native-C libraries....it merely wraps up all the Matlab access calls in a convenient interface. Everything will still run as slowly as it would in Matlab itself. The only real difference between using compiled code with the MCR vs the Matlab Engine is that the Engine gives you a command-line interface which you can use similarly to the Matlab GUI while it's active.

    Of course, another option is to write C files which may be called from Matlab. I don't have much experience with that; however, the first thing you need to decide is which language will be the "host" and which will be the "guest".

    I took a look at the above VC++ add-in. It appears to simply be some convenience stuff using the Matlab Compiler + MCR approach. You can do the same thing without it if you have trouble.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured