How to determine previous input in MATLAB Function block in Simulink?

2 views (last 30 days)
I am trying to simulate Miller-L code in simulink using MATLAB Function block. The input is a Random Integer generator generating binary input 0 and 1 at a rate of 1 KHz. I want to code so that
if Previous_bit == 1
no change in output
else
change output state
end
Hoe can I do this? I tried using loops but didn't work.

Answers (1)

Walter Roberson
Walter Roberson on 3 Dec 2017
You cannot determine the previous input.
If you are using a MATLAB Function block, you could use "persistent" to remember the previous input. If you are using a Level 2 Function then you could use a dwork vector to remember the previous input.
But remember that the previous input might be for a time after the current time.
Consider using a Memory Block, or a First Order Hold, or a Transfer Function, or a Flip Flop.

Products

Community Treasure Hunt

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

Start Hunting!