Using C libraries (FFT) in a s-function simulink

Hello,
I was trying to find the info but couldnt so thats why I am asking here. I hope is not repeated a hundred times.
I am not a huge expert in C programming, but I want to implement in an s-function the possibility to perform the fft. I have downloaded a library (FFTW3) and usually with different compilers I just need to install the library and the include the header file.
The question is, does it work the same way with the matlab compiler? how do I install the library so I can work with matlab? Actually a code that I am using includes the math.h library but I don't know how that library was installed.
I hope I made my point clear. Thank you very much!

Réponses (1)

José-Luis
José-Luis le 14 Oct 2012

0 votes

Two options come to mind, either use a mexfile, that allows you to call C/C++ and Fortran routines from Matlab. A mex-file needs to be compiled (from Matlab), with all related bells and whistles, such as the linking of your library.
Alternatively, call Matlab routines from your C/C++ programs, using Matlab's C/C++ api.

2 commentaires

Thank you for yout fast response.
That's actually what we use in other s-functions. To compile them what I do is typing in the command window mex s_funcxxxx. Then the function is compiled creating a file with the extension mexw32 (i think).
But the problem is that I don't know how to link that library. Do I have to have the library files in the same folder as my s-function? Or there is an specific folder where I should put my new library? or there is a way to install the library so i just have to call it from my code.
Thank you again.
José-Luis
José-Luis le 14 Oct 2012
It's no different than linking libraries in C/C++. If you are going to use mex files, then pass -I -L options to the compiler linking pointing to wherever you library is. Have a look at the mex documentation

Connectez-vous pour commenter.

Catégories

En savoir plus sur Simulink Coder dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by