Why is MATLAB Coder not generating complete code for my function in MATLAB R2023b?
显示 更早的评论
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?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Algorithm Design Basics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!