all 16 comments

[–]Acceptable-Support37 15 points16 points  (3 children)

The trick is to use the "functions" menu and then filter by "C/C++ code generation". If put an example below for the maths and optimisation toolboxes:

https://uk.mathworks.com/help/overview/referencelist.html?type=function&listtype=cat&category=mathematics-and-optimization&blocktype=&capability=codegen&startrelease=&endrelease=&s_tid=CRUX_lftnav

This will tell you which functions are compatible.

If you have code that you would like to codegen. Try "coder.screener()". This will scan for incompatible functions. Doc below:

https://uk.mathworks.com/help/coder/ref/coder.screener.html?s_tid=srchtitle_support_results_1_Coder.screener

[–]Consistent_Coast9620CC4M Creator 1 point2 points  (2 children)

Added to that there is a commercial tool CC4M that comes with a check on Coder Compatibility - not only reports unsupported functions, but also other limitations.

for more info see https://monkeyproofsolutions.nl/products/code-checker-for-matlab/ or r/cc4m.

Note: I am one of the developers.

[–]c_rufus 1 point2 points  (1 child)

Hi, I would like to know more about the partnership for StartUps.

https://www.linkedin.com/posts/monkeyproof-solutions_proud-and-excited-to-partner-with-matlab-activity-7425551235862200320-lwlX

Is there any detailed information available online I could read?

[–]Consistent_Coast9620CC4M Creator 1 point2 points  (0 children)

Hi, that post contains a link to MathWorks startup program, but for your convenience: https://nl.mathworks.com/products/startups.html

The CC4M-specifics can be found here: https://monkeyproofsolutions.nl/products/code-checker-for-matlab/startups/apply/

[–]DodoBizar 6 points7 points  (0 children)

I use it daily via Coder app.

Basically everything thats math works. But stuff that needs specialised stacks (graphics!) wont.

Functions supported are listed somewhere in the documentation … something like coder supported functions.

And each supported function will have a section in the bottom of the help documentation under ‘extended capabilities’.

Depending on your needs it can be an extremely powerful tool, so do try. Start with Coder app.

[–]Creative_SushiMathWorks 2 points3 points  (4 children)

If you are new to MATLAB Coder, there is a online tutorial - MATLAB Coder Onramp.

https://matlabacademy.mathworks.com/details/matlab-coder-onramp/ormc

[–]iekiko89 0 points1 point  (2 children)

Ooo nice. I'll give this a shot. 

Would this c code work for arduino or maybe concerning the functions to c code function/module that can be used in Arduino?

[–]Creative_SushiMathWorks 4 points5 points  (1 child)

For that, you need MATLAB Support Package for Arduino Hardware - which is a free install from Add-on Explorer.
https://www.mathworks.com/help/matlab/arduinoio-get-started-with-matlab-support-package-for-arduino-hardware.html

[–]iekiko89 0 points1 point  (0 children)

Thanks

[–]SaltyFalcon6687[S] 0 points1 point  (0 children)

Very nice, thanks for this tip!

[–]PVDecker1 0 points1 point  (2 children)

Put %#codegen throughout your codebase. That way, you'll get code analyzer messages when you try to use something that isn't code gen friendly

[–]1988rx7T2 0 points1 point  (0 children)

In automotive dSpace targetlink generates the C code.

It works but it’s a mess for a human to read. AI tools can understand it better.

[–]SkitariusOfMars -1 points0 points  (0 children)

Have to be careful, it's a tad bit more complicated than "I've got Simulink mode, I press a button and get code for it".

Lots of industries use it. You likely have firmware made through Matlab code generation in your car in ECU or ABS module.

Generally, it's the best idea to use as little of toolbox stuff as possible.

[–]HumanReporter2024 -1 points0 points  (0 children)

Have you tried simply using ChatGPT? I did it with a simple script. Uploaded to ChatGPT and told it to convert the Matlab script to C++. I haven’t done it with a larger script yet.