Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How to have 3 statements with switches in simulink?

1 visualizzazione (ultimi 30 giorni)
Faris Hajdarpasic
Faris Hajdarpasic il 26 Mar 2019
Chiuso: Stephan il 26 Mar 2019
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.

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by