Converting matlab function to C / C ++

My goal is to get a spectrogram result like in this C ++ article . They have sample source code matlab

and I want to put them in C/C++

. Here are 3 matlab

functions:

I tried to use Matlab Coder

C to generate code and get the result like this: PLCA C

There were many problems with this converted code: it depends on many libs and functions, some methods cannot be ported and I cannot build them.

So I decided to hand over the code and then ran into other problems:

  • The datatype is matlab

    very flexible, for example an array in matlab can add more columns at any time, it can contain another array or vector, so it confuses how to convert it toC++

  • There matlab

    were some supported methods / operations in, and I don't know how to put them in C++

    . For example, circshift

    , zeros

    , divide the two matrices ...

Are there any suggestions?

+3


source to share


1 answer


I have no experience with matlab coder, but we solve this type of problem with simulink code generator. It may sound strange, but it works great. We create a simulink project and add a matlab function block, copy-paste the function there and start generating code.



And of course Matlab doesn't want to show us the key points of its algorithms, so there are libraries in this method as well.

0


source







All Articles