MATLAB: Is the variable not staying updated in Simulink

counterenabled subsystemmatlab function blocksimulinkvariable

Hello,
I am using Simulink and have a variable set to zero in an enabled subsystem. I send the signal out of the subsystem and am trying to update it as x = x + 1 where x is the signal. After simulink goes through all the blocks once and gets back to where x = x + 1 the x is reset to 0. I have a breakpoint in the enabled subsystem where I initialized it and it never goes back there. Any ideas would be appreciated. Thank you!

Best Answer

Actually, I think I figured out what I needed to do. So I declared x as global and found the data store memory block. After I found the block I found http://www.mathworks.com/help/simulink/ug/using-global-data-with-the-matlab-function-block.html#bsdud7d-1 Thank you very much for your time and interest in helping me.