Simulink if/else block

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

 채택된 답변

Steven
Steven 2011년 12월 8일

0 개 추천

the block I was looking for was index vector

추가 답변 (1개)

Kaustubha Govind
Kaustubha Govind 2011년 11월 23일

0 개 추천

There's at least two ways that I can think of:
  1. 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
  2. Use a combination of Logic and Bit Operations (Compare to Constant and AND blocks).

댓글 수: 1

Steven
Steven 2011년 11월 24일
but all logical block send 0 or 1 as output. What's the block to use to take some value if 0, some other if 1

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 General Applications에 대해 자세히 알아보기

질문:

2011년 11월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by