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!

1 件のコメント

PEDRO HENRIQUE Ulhoa
PEDRO HENRIQUE Ulhoa 2021 年 1 月 6 日
Were you able to solve this problem?

サインインしてコメントする。

回答 (1 件)

José-Luis
José-Luis 2012 年 10 月 14 日

0 投票

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 件のコメント

Jose A. de Dios
Jose A. de Dios 2012 年 10 月 14 日
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 2012 年 10 月 14 日
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

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeSimulink Coder についてさらに検索

製品

質問済み:

2012 年 10 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by