What is the best way to mix C and matlab?

  • Context: MATLAB 
  • Thread starter Thread starter beanlet
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

The discussion focuses on integrating C code with MATLAB, specifically for modifying FFT subroutines to utilize MATLAB's spectrum functions. Two primary methods are highlighted: creating a C-MEX file or using the MATLAB Compiler (mcc). The preferred approach discussed is utilizing the MATLAB Engine API, which allows C applications to call MATLAB functions and exchange data seamlessly. Documentation for these methods can be found on the MathWorks website under "C and Fortran API" and "MATLAB Engine."

PREREQUISITES
  • Familiarity with C programming language
  • Basic understanding of MATLAB functions and syntax
  • Knowledge of MATLAB Engine API
  • Experience with creating C-MEX files
NEXT STEPS
  • Research the MATLAB Engine API for C programming
  • Learn how to create and compile C-MEX files in MATLAB
  • Explore the MATLAB Compiler (mcc) for deploying MATLAB applications
  • Review examples on the Numerical Recipes website for practical implementations
USEFUL FOR

Software developers, engineers, and researchers looking to integrate C applications with MATLAB for enhanced computational capabilities, particularly in signal processing and numerical analysis.

beanlet
Messages
6
Reaction score
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.
 
Physics news on Phys.org
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
 
There is also an example on the Numerical Recipes site. www.NR.com

Thanks
 
Thank you so much! Yes, calling MATLAB from C is what I need. :smile:
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
922
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
7K