What is the best way to mix C and matlab?

  • Topic: MATLAB 
  • Thread starter Thread starter beanlet
  • Start date Start date
  • Tags Tags
    Matlab
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
3 replies · 3K views
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
 
Thank you so much! Yes, calling MATLAB from C is what I need. :smile: