Trouble understanding the Code Generation Advisor Messages

6 次查看(过去 30 天)
My understanding about SIMULINK advisor
SIMULINK advisor is there so that modellers do not make silly mistakes that could cause an error in code generation and rapid prototyping. The target is to pass all the models without any warnings so that the code generation activity is smooth.
My problem
I have a model that is currently encountering only one warning message in the code generation advisor. The category is Identify blocks using one-based indexing. I understand what 1 (MATLAB) and 0 (usually in C, Java, etc.) based indexing are. But I am failing to understand why this is popping up all the time. I assume that because my TL is C and C uses 0 based indexing, Code Generation Advisor is suggesting that I check for 1-based indexing. I cannot seem to find out what is wrong.
The problem is coming from a MATLAB func block that I am using in SIMULINK model. Due to confidentiality reason, I cannot put the actual content of the file, but can alter the text and provide a technically identical version of the function that is being reported to have "1-based indexing" issue in the advisor dashboard.
function y = IDENT_TABLE(ID_1_INTERNAL, ID_2_INTERNAL, ID_3_INTERNAL)
if ID_3_INTERNAL == 1
y = 1;
else
y = 0;
end
I would really appreciate an explanation :)
Thanks in advance,

采纳的回答

Bhavani
Bhavani 2013-7-23
The 'Identify blocks using one-based indexing' check recommends using zero-based indexing for all blocks in your model to increase execution efficiency of the generated code. In this case, the MATLAB Function block requires one-based indexing, so you cannot configure it to use zero-based indexing. You can consider replacing the MATLAB Function block with Simulink basic blocks using zero-based indexing, if that is possible.
If you need to use a MATLAB Function block, and are using R2012a or later release of MATLAB, you can consider excluding this block from this check during analysis, so that the check will not flag this block. This is however only available when running the check through the Model Advisor, and is not currently available through the Code Generation Advisor. See http://www.mathworks.com/help/slvnv/ug/excluding-blocks-from-model-advisor-checks.html for more information on exclusions.
  1 个评论
Mohammed Manna
Mohammed Manna 2013-7-23
Thanks....Already solved this by applying a CL circuit:
1) Input ID_1_INTERNAL, ID_2_INTERNAL to an Invert AND (not NAND) gate. 2) Input ID_3_INTERNAL and the output from above to an AND gate.
In this way it is also time-independent (of course, there is a propagation/physical delay which no one can stop).

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Sources 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by