Why does the code generated following "Generate C++ Classes from MATLAB Classes Using MATLAB Coder" differ from the code shown in the video?

I am following the "Generate C++ Classes from MATLAB Classes Using MATLAB Coder" example, which can be found here: https://www.mathworks.com/videos/generate-c-classes-from-matlab-classes-using-matlab-coder-1594020157369.html
I am using MATLAB R2021a and I believe I have followed the video exactly when creating the MATLAB handle class and using MATLAB coder to generate the C++ class, but the code I generate does not look the same as what is shown in the video. I do not get the "simpleClass.cpp" or "simpleClass.h" files, which are generated in the video.
Could you help me understand why the output is different?

 採用された回答

MathWorks Support Team
MathWorks Support Team 約9時間 前
編集済み: MathWorks Support Team 約5時間 前
This is due to an optimization setting for inlining user functions introduced in MATLAB R2020b after this video was created in MATLAB R2020a.
There are four options that were introduced for the 'InlineBetweenUserFunctions' code configuration object:
  • 'Always': Always perform inlining at a call site.
  • 'Speed': Uses internal heuristics to determine whether to perform inlining at a call site. This setting is the default setting.
  • 'Readability': Almost never inlines function calls, except for calls to very small functions.
  • 'Never': Never inlines function calls.
Since the default is now set to 'Speed', the functions were inlined to created more optimized code, but the generated code still works the same as the code in the video.
 
There are two ways to modify this setting: using the command line to set the 'InlineBetweenUserFunctions' object or through the app.
If you would like to see or edit this setting while in the app:
  1. Click 'Generate' and this will open the code generation window.
  2. From here, click 'More Settings'
  3. Next, go to 'All Settings', scroll down to the section called 'Advanced'.
  4. Here you will find the function inlining settings where you will see the setting 'Inline between user functions'
For more information, please refer to the "Control Inlining to Fine-Tune Performance" documentation:

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGenerating Code についてさらに検索

製品

リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by