Simulink - How to create a conditional "if" block
조회 수: 13 (최근 30일)
이전 댓글 표시
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
Umar
2024년 6월 21일
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.
채택된 답변
Paul
2024년 6월 21일
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
Umar
2024년 6월 23일
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.
추가 답변 (1개)
Sam Chak
2024년 6월 21일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Two-Phase Fluid Library에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!