Target Language Compiler | ![]() ![]() |
Fix the Bug and Verify the Fix
The problem we identified is caused by evaluating a constant rather than a variable inside the TLC function FcnEliminateUnnecessaryParams(). This is a typical coding error and is easily repaired. Here is the code we need to fix:
%function FcnEliminateUnnecessaryParams(y,u,k) Output %if LibIsEqual(k, "0.0") %if ShowEliminatedStatements == 1 /* %<y> = %<u> * %<k>; */ %endif %elseif LibIsEqual(k, "1.0") %<y> = %<k>; %elseif LibIsEqual(k, "-1.0") %<y> = -%<k>; %else %<y> = %<u> * %<k>; %endif %endfunction
Testing the constant parameter k
against 0.0, 1.0, and -1.0 is fine; the problem occurs in the assignment of y
to k
in the latter two cases:
gain.tlc
.
y
is correctly assigned inside FcnEliminateUnnecessaryParams. Complete the build by typing continue
at each TLC-DEBUG> prompt.
!simple_log
. A new version of simple_log.mat
is created containing its output.
rt_yout
with yout
, as you did before. All values in the first column should now correspond.
For more information about the TLC debugger, see Debugging TLC Files.
![]() | Debug gain.tlc | Using TLC Code Coverage to Aid Debugging | ![]() |