SIMULINK holding previous values of a signal

2 views (last 30 days)
I am trying to implement a pulse generator in SIMULINK that needs to know the previous 2 input values i.e. I need to know the previous 2 state values for the input signal. Also, I need to know the previous output value.
My pseudo code is:
IF !input AND input_prevValue AND !input_prevValue2
output = !output_pv
ELSE
output = output_pv;
In my actual C code, I have declared input_prevValue, input_prevValue2 and output_prevValue as static. However, it creates problem when I use the model advisor to check it. It suggests that the function cannot be inlined and need to set the non-inline function support option (in code generation pane). When I did it, it still says that the "Suppress error status" option should be disabled. I am really confused what to do. Is it a limitation of SIMULINK
My solution would be to implement the logic in a way that I can do the same without C functions. I tried to use the memory block in SIMULINK but apparently it doesn't do it. Does anyone know how to hold previous values for input and output in SIMULINK (for as long as the model is open)?

Answers (0)

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!