Simulink - How to create a conditional "if" block
Mostrar comentarios más antiguos
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 comentarios
Umar
el 21 de Jun. de 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.
Ahmad Al-Issa
el 21 de Jun. de 2024
Respuesta aceptada
Más respuestas (1)
Sam Chak
el 21 de Jun. de 2024
0 votos
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 comentarios
Ahmad Al-Issa
el 21 de Jun. de 2024
Editada: Ahmad Al-Issa
el 21 de Jun. de 2024
Sam Chak
el 21 de Jun. de 2024
Thank you for your clarification. Please consider describing the logic using multiple IF–THEN rules and update the question so that people understand what you are asking for. At this point, I am still unable to fully grasp it.
For instance, if the speed fluctuates between 55 rpm and 65 rpm (not yet drop below 50 rpm and not yet rise above 70 rpm), should Equation #1 or Equation #2 be used?
I have a feeling that your switching logic must maintain a persistent memory of which Equation is being used in the "existing state" when the speed fluctuates between 55 rpm and 65 rpm.
Ahmad Al-Issa
el 21 de Jun. de 2024
Ahmad Al-Issa
el 21 de Jun. de 2024
Editada: Ahmad Al-Issa
el 21 de Jun. de 2024
Categorías
Más información sobre General Applications en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


