I don't understand MATLAB coder to C

1 Ansicht (letzte 30 Tage)
Joel Biosca Llorente
Joel Biosca Llorente am 14 Feb. 2023
Beantwortet: Swaraj am 7 Mär. 2023
Hi, I am developing a mechanic fluids code which has a main, called for example SW, and it calls the functions p1,p2,ph,pp. Some of that functions call other functions called sbreminus, sbreplus...
My problem is how to introduce the functions to the matlab coder, because all the examples are made with so easy code that doesn't call more than one function.
At the first step, entry-point functions, should I insert all functions?
Then the script that exercises the functions should be the main SW?
then there are generated archives of source code which names end with _initialize.c, _data.c... , what should I compile and run to make the script run?
Or should I use the coder more than once to code to c all functions?
Thanks
  1 Kommentar
Walter Roberson
Walter Roberson am 14 Feb. 2023
  • tell the coder the name of the entry-point file. It will examine the file to figure out what is called, and will examine those files to figure out what they call, and those will be examined, and so on
  • if you have any files being called by name in a quoted string, such as by using feval('NAME') or using fmincon('NAME') or ode45('NAME') then you will need to either use a %#function pragma or else add those functions to the project
  • if you saved an object previously and you load the object in the code (for example, you load a trained convolutional net) then you will probably need to add the class of the object.
  • You do not typically need to explicitly tell the coder the names of all called functions; it can usually figure out everything other than the call-by-name and load cases.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Swaraj
Swaraj am 7 Mär. 2023
You must write an entry-point function that invokes each function your main function needs in order to introduce numerous functions to the MATLAB Coder. In your situation, the entry-point function might call the “p1”,”p2”, “ph”, and “pp” functions. Each of these functions might then call the “sbreminus ” and “sbreplus” functions.
After creating your entry-point function, you may use the MATLAB Coder to produce the C code. The relevant functions and any necessary header files will be included in the resulting code. The resulting code can subsequently be converted into a standalone executable or a shared library that other programmes can use.
You can develop a test script in MATLAB that calls your entry-point function and compares the output to the anticipated outcome to validate the created code.
Below is the documentation link for more details.

Kategorien

Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by