Simulink if/else block
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I'm looking for the right way to set a conditional statement in Simulink. That's the pseudo-code I wish to have:
if x < 6
y = 0
elseif x > 20
y = 2
else
y = 1
The block if is not really what I'm looking for, I just want a small controller with one input (x) and one output (y).
thx
0 个评论
采纳的回答
更多回答(1 个)
Kaustubha Govind
2011-11-23
There's at least two ways that I can think of:
- Use a 1-D Lookup Table with [0 1 1 2] as the table data and [6-eps 6 20 20+eps] as the breakpoints
- Use a combination of Logic and Bit Operations (Compare to Constant and AND blocks).
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!