Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Generate code from simulink
Replies: 1   Last Post: Nov 11, 2012 4:15 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
cesar

Posts: 1
Registered: 11/11/12
Generate code from simulink
Posted: Nov 11, 2012 3:53 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.