0
0
Simulinkdata~20 mins

Model configuration for code generation in Simulink - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Simulink Code Generation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of code generation configuration command
What is the output of the following MATLAB command configuring code generation in Simulink?

cfg = coder.config('exe');
cfg.GenerateReport = true;
cfg.TargetLang = 'C';
disp(cfg.GenerateReport)
Simulink
cfg = coder.config('exe');
cfg.GenerateReport = true;
cfg.TargetLang = 'C';
disp(cfg.GenerateReport)
A0
Bfalse
C1
Dtrue
Attempts:
2 left
💡 Hint
Check the property type of GenerateReport in coder configuration objects.
data_output
intermediate
2:00remaining
Number of code generation targets available
Using MATLAB's coder API, how many code generation target languages are available by default?
Simulink
langs = coder.targetLangs();
numLangs = numel(langs);
disp(numLangs)
A4
B3
C5
D6
Attempts:
2 left
💡 Hint
Common target languages include C, C++, and others.
🔧 Debug
advanced
2:00remaining
Identify the error in code generation configuration
What error will occur when running this code snippet configuring Simulink code generation?

cfg = coder.config('dll');
cfg.TargetLang = 'Python';
Simulink
cfg = coder.config('dll');
cfg.TargetLang = 'Python';
AError: Invalid target language specified
BNo error, configuration accepted
CSyntaxError: invalid syntax
DTypeError: unsupported operand type
Attempts:
2 left
💡 Hint
Check the allowed values for TargetLang property.
🧠 Conceptual
advanced
2:00remaining
Effect of setting 'GenerateReport' to false
What is the effect of setting the 'GenerateReport' property to false in a Simulink code generation configuration?
AThe generated code will be optimized for speed
BNo code generation report will be created after build
CCode generation will fail due to missing report
DThe build process will run in debug mode
Attempts:
2 left
💡 Hint
Think about what a report is used for after code generation.
🚀 Application
expert
3:00remaining
Choosing the correct configuration for embedded C code generation
You want to generate optimized embedded C code from a Simulink model for deployment on a microcontroller. Which configuration object should you use and what key property must be set to ensure the code is suitable for embedded deployment?
AUse cfg = coder.config('lib'); set cfg.TargetLang = 'C'; set cfg.EnableCustomCode = true;
BUse cfg = coder.config('exe'); set cfg.TargetLang = 'C'; set cfg.EnableVariableSizing = false;
CUse cfg = coder.config('dll'); set cfg.TargetLang = 'C'; set cfg.EnableVariableSizing = false;
DUse cfg = coder.config('lib'); set cfg.TargetLang = 'C++'; set cfg.GenerateReport = true;
Attempts:
2 left
💡 Hint
Embedded code often requires fixed-size variables and a dynamic library format.