Embedded coder on m-files (without simulink)

5 views (last 30 days)
Is matlab coder and embedded coder suitable to generate c code (for embedded target) from an m-file, and if so, how? I only find examples involving simulink, but is there a way to do this from command line (achieving rtwbuild with ert on m-file only).
If done form within Simukink om an Matlab System block only, is Simulink coder necessary?

Accepted Answer

Andreas Johansson
Andreas Johansson on 30 Jan 2019
I think that answers it. What I ment by that phrase was just if embedded coder could be accesed and used from Matlab and Matlab coder, independednt from Similumk, and that seems to be the case. I will try it out and see, maybe Matlab coder will be enough.
Thanks for support

More Answers (2)

Denis Gurchenkov
Denis Gurchenkov on 28 Jan 2019
MATLAB Coder is exacrtly the tool that takes an .m file and genrates C code from it. If all you want is MATLAB-to-C conversion, then you don't need Simulink or Simulink Coder at all. If you go to https://www.mathworks.com/products/matlab-coder.html and start from there, there are tutorials, webinars and all that reachable from that page (you do need to create a free MathWorks account to get to the doc, though).
If you have a Simulink model with a single MATLAB Function Block in it and you want to generate C code, then you do need Simulink Coder. But if you took the body of that block, saved it in an .m file, then you could feed that file to MATLAB Coder and then you don't need Simulink Coder.

Andreas Johansson
Andreas Johansson on 29 Jan 2019
Thanks, that what I was hoping for, and what we wants to do (your last proposal). My only remainin question then, is if embedded coder (ert) can be hooked on to this chain so to speak? We have licenses of Matlab coder, but I was unable to verify this alternative (Maybe because we dont have embedded coder yet, or if I was not used to the tool interface).
  1 Comment
Denis Gurchenkov
Denis Gurchenkov on 29 Jan 2019
If you have a license for Embedded Coder, it unlocks extra features in both SL and ML Coders, allowing for greater customization of generated code (things like naming style for variables). You can always generate C code without Embedded Coder (via either SL or ML coder, depending on your source language -- Simulink or MATLAB), and Embedded Coder only is necessary if there is some particular feature (like code customization, interfacing with extrenal C code etc) that you need -- many such features get unlocked / become visible in configuration menus only if Embedded Coder license is available.
Can you elaborate on what you mean by "embedded coder can be hooked on to this chain"? If you have both ML and Embedded Coder licenses, they would work together just fine, but the real question is, what is the feature or capability of Embedded Coder that you really need.
To sum it up, perhaps you should try first to generate C code using ML coder alone. If taht works (C code is generated and does what you want) then you decide if you want/need to try EC or not.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by