Simulink - How to create a conditional "if" block
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Dear experts, @Stephen23
I have a simulink model, in this model there are two senarios. (heating and cooling)
1- heating: The 1st eq applies when the tempreature increases from 50 to 70 C
2- cooling: The 2nd eq is applied when the tempreature decreases from 70 to 50 C
So, when the tempreature goes from 50 to 70, I use the 1st eq. Until the tempreature reaches >=70 and start runing the cooling unit and using the 2nd eq. Until the tempreature reaches <=50. and so on.
the initial condition is the tempreature is 50 and start heating.
How can I create blocks for this purpose in simulink.
Thank you.
2 Commenti
Umar
il 21 Giu 2024
Hi Ahmad, To implement speed-dependent equations in Simulink, you can use the "Switch" block along with a combination of "Relational Operator" blocks to compare the speed values and switch between equations accordingly.
Here's a high-level overview of how you can achieve this:
Use a "Relational Operator" block to compare the speed signal with the threshold values (e.g., 50 and 70 rpm). Connect the output of the "Relational Operator" blocks to a "Switch" block to select between the two equations. Implement your equations in separate subsystems or blocks and connect them to the "Switch" block based on the condition. By setting up the conditions and connecting the blocks appropriately, you can create a dynamic system in Simulink that switches between equations based on the speed thresholds specified. This approach allows for a flexible and efficient way to model speed-dependent behavior in your simulation.
Risposta accettata
Paul
il 21 Giu 2024
Perhaps you can use a Relay block to model the desired behavior based on the heating/cooling analogy. The output of the Relay can be used to drive a Switch the controls which equation is used, or a pair of Enabled subsytems. Probably other options as well.
9 Commenti
Umar
il 23 Giu 2024
No problem Ahmad, as a team working together, you did achieve your goal. Paul was really helpful throughout this process. Kudos to Paul for his efforts.
Più risposte (1)
Sam Chak
il 21 Giu 2024
Firstly, could you determine the rate of change of speed (referred to as "acceleration" in physics)? This information is necessary to ascertain whether the speed is increasing from 50 rpm to 70 rpm or decreasing from 70 rpm to 50 rpm, and to apply the corresponding equation.
If your model does not directly measure acceleration, you may need to estimate it using mathematical functions or Simulink blocks. If you have a specific mathematical function, please provide it.
Strictly speaking, only the sign of acceleration is needed. If acceleration is positive, Equation #1 should be applied; if negative, Equation #2.
There are two additional issues to address:
- What happens if the speed remains constant at any value between 50 rpm and 70 rpm (e.g., 60 rpm) at the initial simulation? Is there a third equation for this scenario?
- If the speed increases linearly from 50 rpm and Equation #1 is applied, but then decreases from 60 rpm onwards without reaching 70 rpm, should Equation #1 or Equation #2 be used?
4 Commenti
Vedere anche
Categorie
Scopri di più su Two-Phase Fluid Library in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!