How can matlab coder be configured to generate only one c file?

My problem is this: similarly, I can generate only one model.c and model.h file in simulink coder by setting the "File packaging format" to "compact". and model.h files, but if I don't use simulink coder, how can I generate only one c file/header file for my algorithm via Matlab coder app or command line control in this way? Thanks in advance
simlar issue:
------------------------------
Update to clarify:
I mean actually generate only one ".c" and the corresponding ".h" file, not Instead of following the steps below, select "Generate all functions into a single file". Because this generates additional files, such as <name>_type.h, etc.
Using the MATLAB Coder App
  1. To open the Generate dialog box, on the Generate Code page, click the Generate arrow .
  2. Click More Settings.
  3. On the Code Appearance tab, set the Generated file partitioning method to Generate one file for each MATLAB file or Generate all functions into a single file.

Answers (1)

Yes you can tell MATLAB Coder to generate a single file. Here is the doc page.

5 Comments

@Denis Gurchenkov Sorry, you didn't understand me completely, what I meant was to actually generate only one ".c" and the corresponding ".h" file, not "Generate all functions into a single file". But the official documentation generates some additional files like <name>_emxutil.c/h, <name>_type.h, and so on. These files should be integrated into the <name>.h/.c file.
You can refer to the link to my similar question above
Ah, I see now, thanks for clarifying!
I don't think such a feature exists in the MATLAB Coder product. I am creating a feature request for the development team based on your suggestion. To strenghten the case and help the dev team to prioritize this, can you please add a little bit of description - how would you use the generated code, how the single file scheme would be useful for you?
Thanks,
Denis.
Thanks for helping me prioritize this enhancement, as fewer C files are very easy to port to embedded hardware, especially exposing only the C interface functions (multiple entry functions in matlab coder) and basic built-in C base data types for the user to use. Instead of generating a bunch of matlab custom types involving dynamic memory allocation such as emx_* or supporting nonfinitite type files each time. mathworks should consider exposing as few such custom types as possible for the user for the purpose of ease of use and would not consider so many matlab coder products for the solution.
Looking forward to the next version of matlab coder app supporting
interactive option.
Unfortunately I don't see this enhancement in the new version R2022b which has just been released. Personally I don't see a technical problem with this new feature, the simulink coder/embeded coder can generate the model as a separate .h and .cpp file. I wonder if matlab coder will be introduced with any importance in R2023a?
Reference
Amalgamate,A cross platform command line tool for producing an amalgamation of C or C++ sources.

Sign in to comment.

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Release

R2021a

Asked:

on 11 Mar 2022

Edited:

on 16 Sep 2022

Community Treasure Hunt

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

Start Hunting!