What is the best way to mix C and matlab?

  • MATLAB
  • Thread starter beanlet
  • Start date
  • #1
6
0
Hey,

I need to modify some C codes, but I want to change the original FFT subroutine into someway that calls matlab spectrum functions. I checked the matlab help document, but still have not decided which way to go: (1) C-MEX file; (2) mcc.

There must be some other way to go, but I have not learned enough. Anybody here is familiar with this kind of thing? Would you please give me some suggestions, or recommended approaches?

Thank you very much.
 

Answers and Replies

  • #2
175
1
Would you prefer to call MATLAB routines from C, or C from MATLAB? I don't have any experience with calling C from MATLAB, but calling MATLAB from C is pretty easy, you just need to use the MATLAB engine API.

This will let you run an instance of MATLAB from within your C app, and you can exchange data between MATLAB and your app, and make any MATLAB calls you like.

Documentation is on the Mathworks web site. Look for "C and Fortran API" and "MATLAB Engine."

Hope this is what you're looking for.

-Kerry
 
  • #3
783
9
There is also an example on the Numerical Recipes site. www.NR.com

Thanks
 
  • #4
6
0
Thank you so much! Yes, calling matlab from C is what I need. :smile:
 

Related Threads on What is the best way to mix C and matlab?

Replies
10
Views
3K
Replies
3
Views
5K
Replies
0
Views
1K
Replies
1
Views
3K
Replies
1
Views
3K
Replies
2
Views
922
  • Last Post
Replies
6
Views
1K
  • Last Post
Replies
8
Views
3K
Replies
16
Views
26K
  • Last Post
Replies
2
Views
4K
Top