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

5 次查看(过去 30 天)
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.

回答(1 个)

Walter Roberson
Walter Roberson 2017-12-3
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.

类别

Help CenterFile Exchange 中查找有关 String 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by