Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


cesar
Posts:
1
Registered:
11/11/12


Generate code from simulink
Posted:
Nov 11, 2012 3:53 PM


Hello I am using simulink to generate code for an embedded system and I want to implement a counter that is increased every time someone presses a button, to this I add the embedded matlab function block and I have the following code:
function [x, y, z] = fcn(u) %#eml
x = uint8(0); y = uint8(0); z = uint8(0); counter = uint8(0);
if(u == 1) counter = counter + 1; end
if(counter > 5); x = uint8(1); end if(counter > 10); y = uint8(1); end if(counter > 15); z = uint8(1); end end
simulink then generates no counter part, but if the remainder I tried changing the way of doing the count but still generate. The system does not show error message, so what settings should I continue to force Simulink to generate this code? Thank's for any help



