Why is MATLAB Coder not generating complete code for my function in MATLAB R2023b?
Show older comments
I have a MATLAB function that takes a row or column vector, performs some vector computations, removes the first and last elements of the vector, and then returns the vector among other outputs.
When I generate code for this MATLAB function using a basic MATLAB Coder configuration/generation script, the output code is much smaller than expected and missing much of the logic. I see sections with comments indicating what the original MATLAB source code was but then see no actual C++ translation.
When I use the MATLAB Coder GUI instead of my script, the same outcome happens; however, when it checks for run-time errors, some potential errors are flagged. When I use the script, no runtime errors are flagged, so I'm not sure what to make of this.
For context, this is my code generation script:
%% Create configuration object of 'coder.EmbeddedCodeConfig'.
cfg = coder.config('lib','ecoder',true);
cfg.GenerateExampleMain = "GenerateCodeOnly";
cfg.FilePartitionMethod = 'SingleFile';
cfg.TargetLang = 'C++';
cfg.MATLABSourceComments = true;
currentDir = pwd;
cppCodeDir = fullfile(currentDir,'Cpp-Code');
fnNameForCodegen = 'myFunctionForCodegen';
% Note: myArgs is defined above outside snippet.
codegen('-config', cfg, '-d', cppCodeDir, fnNameForCodegen, '-args', myArgs);
Why is the code not generating completely, and how can I get it to generate completely?
Accepted Answer
More Answers (0)
Categories
Find more on Algorithm Design Basics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!