MATLAB What is the best way to mix C and matlab?

  • Thread starter Thread starter beanlet
  • Start date Start date
  • Tags Tags
    Matlab
AI Thread Summary
The discussion revolves around modifying C code to integrate MATLAB's spectrum functions, with the user considering options like C-MEX files and mcc for implementation. The preferred approach highlighted is calling MATLAB from C using the MATLAB engine API, which allows for running MATLAB instances within C applications and facilitates data exchange and function calls. Documentation and examples are available on the Mathworks website and Numerical Recipes, providing guidance for those unfamiliar with the process. The user confirms that calling MATLAB from C aligns with their needs.
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
4
Views
1K
Replies
3
Views
2K
Replies
1
Views
2K
Replies
12
Views
4K
Replies
4
Views
2K
Replies
10
Views
4K
Back
Top