Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How to have 3 statements with switches in simulink?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello. So I am confused with switches in simulink. Basically they gives you 2 options. If and else. But I dont know how to realise third statement(to have: if, else if and else). I tried with 2 switches, but I end up again on only on: if and else options. So I will present my problem(I will use constant C as example) If C>10 display 1000 Else if (C>5 && C<=10) display 500 else display 200
So I tried to connect 2 switches(first one have statement >5, second one >10), and I set result from this one to be statement for second switch, and second switch is connected to display(so that means that I can display only 2 values - values that are connected to switch2(as if and else statement)). Basically I dont know how to display last case(to display 20p). So this happens for specific value of constant C.
<<www-mathworks-com-matlabcentral-answers-uploaded_files-210507-15536154111676378146889612444445.jpg>>
C=20(that is >5 and result from switch1 become statement for switch 2, and for that switch it is also 20>5 and it displays 1000)
C=7(that is >5 and for switch2 that is NOT >10, and else from switch 2 goes to display, and it displays 500)
C=2(that is NOT >5 and now else(as result of this statement from switch1) become statement for switch2 for which is NOT 2>10 and result is that else from switch2 and it displays 500. But for this case it should display 200)
So that is the problem. For example.
댓글 수: 0
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!