Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

calling matlab in C... if possible then how?

Status
Not open for further replies.

cedance

Advanced Member level 2
Joined
Oct 24, 2003
Messages
551
Helped
30
Reputation
60
Reaction score
7
Trophy points
1,298
Location
Germany
Activity points
4,622
calling matlab dll from c

hi,

i am in need of calling matlab from with in C program for calculating a prt of the output. This has to be fed to the next stage. how can i invoke matlab from within C environment to do this? is it possible similar to running some dos comands within C? if not is it possible to do cluster computing with matlab(running a program on several comp. by splitting them into independent modules)... if so how to do it?.. and i know abt the distributed computing toolbox that has been issued by mathworks just now... which was not avaibale in the m14sp1 release...

/cedance
 

c invoke matlab

See whether the following articles will help:

Solving Engineering Problems Using MATLAB C API
**broken link removed**

MATLAB Shared Library
https://www.codeproject.com/dll/MatlabSharedLib.asp

Solving Engineering Problems Using MATLAB C++ Math Library
**broken link removed**
 

    cedance

    Points: 2
    Helpful Answer Positive Rating
calling matlab function from c

nicleo said:
See whether the following articles will help:

Solving Engineering Problems Using MATLAB C API
h**p://www.codeproject.com/samples/matlab_c_api.asp

MATLAB Shared Library
h**p://www.codeproject.com/dll/MatlabSharedLib.asp

Solving Engineering Problems Using MATLAB C++ Math Library
h**p://www.codeproject.com/samples/MATLAB_Cpp.asp

i need to call matlab from C and not the other way! thou, thanks for the links. was useful. i need it anyway.

/cedance
 

Re: calling matlab in C... possible?

arunmit168 said:
i need to call matlab from C and not the other way! thou, thanks for the links. was useful. i need it anyway.
I think the links show examples that call matlab function from/in C. Pls correct me if I'm wrong. Thanks.

Code:
Using C Math Library

To add support of MATLAB C Math Library follow these instructions:
1- Add following line at the end of stdafx.h

#include <matlab.h>

matlab.h is interface of MATLAB APIs. Add directory of MATLAB interface files (*.h) to Visual Studio (Tools -> Options -> Directories). For example: x:\matlab\extern\include where x is drive letter of matlab path.

2- Add desired libraries to your project (In this example, libmat.lib, libmx.lib, libmatlbmx.lib and libmatlb.lib)

3- Compile your project!
Sample Program

#include "stdafx.h"

int main(int argc, char* argv[])
{
double dblArray[]={1, 2, 3, 4, 5, 6, 7, 8, 9};

mxArray *A, *B; A=mxCreateDoubleMatrix(3, 3, mxREAL);

//copy array to matrix A

memcpy(mxGetPr(A), dblArray, 9 * sizeof(double));

A=mlfMTimes(A, A); //A=A.^2;

mlfPrintMatrix(A); //Creating Magic Matrix

B=mlfMagic(mlfScalar(3)); //Magic matrix of order 3 

mlfPrintMatrix(B);

mxDestroyArray(A);

mxDestroyArray(B);

return 0; }
 

Re: calling matlab in C... possible?

yeh, i think u are right, can try with C. thanks. will try it and reply.

/cedance
 

Re: calling matlab in C... possible?

Yes, of course you can.
The most recommended method connecting C and matlab is MBuilder.
You can find help in matlab soft.

Good luck!
 

Re: calling matlab in C... possible?

yes it is possible,
you can use a generic perl script also for that.
 

TRY THIS LINK.....

I THINK IT HAS GOT UR ANSWER
**broken link removed**
 

mexx said:
I THINK IT HAS GOT UR ANSWER
h**p://tiger.la.asu.edu/Matlab/call_c_functions.htm
There is a demo program given in the link above:

myprog.c

But it's a demo of calling a C function from MATLAB

If I'm not mistaken, arunmit168 is looking for a solution of calling matlab (function) from C program :)
 

But it's a demo of calling a C function from MATLAB

If I'm not mistaken, arunmit168 is looking for a solution of calling matlab (function) from C program Smile

i think i made the same mistake that u made beforenicleo
anyway sorry for the post

mexx
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top