How to determine previous input in MATLAB Function block in Simulink?
2 次查看(过去 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.
0 个评论
回答(1 个)
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 Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!