MATLAB Code
himl_0004: MATLAB Code Analyzer recommendations for code generation
ID: Title | himl_0004: MATLAB® Code Analyzer recommendations for code generation | ||
---|---|---|---|
Description | When using MATLAB code: | ||
A | To activate MATLAB Code Analyzer messages for code generations, use the
%#codegen directive in external MATLAB functions. | ||
B | Review the MATLAB Code Analyzer messages. Either:
| ||
Notes | The MATLAB Code Analyzer messages provide identifies potential errors, problems, and opportunities for improvement in the code. | ||
Rationale | A | In external MATLAB functions, the %#codegen directive activates
MATLAB Code Analyzer messages for code generation. | |
B |
| ||
Model Advisor Checks | Check MATLAB Code Analyzer messages (Simulink Check) | ||
References |
| ||
See Also | |||
Last Changed | R2016a | ||
Examples | Recommended
Not Recommended
|
himl_0006: MATLAB code if / elseif / else patterns
ID: Title | himl_0006: MATLAB code if / elseif / else patterns |
---|---|
Description | For MATLAB code with |
Rationale |
|
Model Advisor Checks | Check if/elseif/else patterns in MATLAB Function blocks (Simulink Check) |
References |
|
See Also | |
Last Changed | R2018b |
Examples | Recommended
Not Recommended
|
himl_0007: MATLAB code switch / case / otherwise patterns
ID: Title | himl_0007: MATLAB code switch / case / otherwise patterns |
---|---|
Description | For MATLAB code with
|
Note | If there is only one
|
Rationale |
|
Model Advisor Checks | Check switch statements in MATLAB Function blocks (Simulink Check) |
References |
|
See Also | |
Last Changed | R2018b |
Examples | Recommended
Not Recommended
|
himl_0008: MATLAB code relational operator data types
ID: Title | himl_0008: MATLAB code relational operator data types |
---|---|
Description | For MATLAB code with relational operators, use the same data type for the left and right operands. |
Note | If the two operands have different data types, MATLAB will promote both operands to a common data type. This can lead to unexpected results. |
Rationale |
|
Model Advisor Checks | Check usage of relational operators in MATLAB Function blocks (Simulink Check) |
References |
|
See Also | |
Last Changed | R2024a |
Examples | Recommended
Not Recommended
|
himl_0010: MATLAB code with logical operators and functions
ID: Title | himl_0010: MATLAB code with logical operators and functions |
---|---|
Description |
For logical operators and logical functions in MATLAB code, use logical data types |
Notes |
Logical operators: Logical functions: |
Rationale |
|
Model Advisor Checks | Check usage of logical operators and functions in MATLAB Function blocks (Simulink Check) |
References |
|
Last Changed | R2024a |
Examples |
Recommended
Not Recommended
|
himl_0012: Usage of MATLAB functions for code generation
ID: Title | himl_0012: Usage of MATLAB functions for code generation | ||
---|---|---|---|
Description | Use only MATLAB functions that support code generation. | ||
Rationale | To detect and avoid the usage of MATLAB functions which are not supported by code generation at earliest possible stages of development. | ||
Model Advisor Checks | Check MATLAB functions not supported for code generation (Simulink Check) | ||
References |
| ||
See Also | coder.screener Functions | ||
Last Changed | R2021b |
himl_0013: Limitation of built-in MATLAB Function complexity
ID: Title | himl_0013: Limitation of built-in MATLAB Function complexity | ||||||
---|---|---|---|---|---|---|---|
Description | When authoring MATLAB code, limit the usage of built-in MATLAB functions that may result in generated code that exceeds complexity limits established for your project. | ||||||
Notes | Complexity limits can vary across projects. Typical limits might be as described in this table:
| ||||||
Rationale | Improve testability and maintainability. | ||||||
Model Advisor Checks | Metrics for generated code complexity (Simulink Check) | ||||||
References |
| ||||||
Last Changed | R2024a |