MATLAB: Do I obtain incorrect results from S-Function Builder with multiports demo in Simulink 6.6 (R2007a)

simulink

When I run the S-Function Builder with Multiports demo
sfbuilder_multiport
I obtain incorrect results from the output "out1".
I should receive the sum of the two input signals "in1" and "in2" instead of the "in1" input signal multiplied by 2.
To be more specific, you can see that "in1" is:
[1 3 5;2 4 6]
and "in2" is:
[6 8 9;3 2 7]
but "out1" is:
[2 6 10;4 8 12]
instead of
[7 11 14;5 6 13]

Best Answer

There is an error in the "S-Function Builder with Multiports" demo in Simulink 6.6 (R2007a).
To work around this issue, replace the code on line 10 in the "Outputs" panel of the S-Function Builder dialog box from:
out1[i] = (int8_T) (in1[i]) + (int8_T) (in1[i]);
with the following:
out1[i] = (int8_T) (in1[i]) + (int8_T) (in2[i]);