check if input data in simulink changes by a certain specific value

3 ビュー (過去 30 日間)
Aadithya Iyer
Aadithya Iyer 2022 年 4 月 17 日
回答済み: Andy Bartlett 2022 年 4 月 19 日
I am working in Simulink where I have a few discharge profiles as input data. The input data varies randomly like a drive cycle. say my starting value is 70. If I want to now check when the value changes to 60 and trigger another system. But this trigger should happen every interval of change in value by 10. So first trigger happens when the value reaches 60, next happens at 50 and so on. I tried creating a Matlab function block using stored memory read write blocks to store these value but not able figure out how to actually make this work.
Looking for help here. thanks

回答 (1 件)

Andy Bartlett
Andy Bartlett 2022 年 4 月 19 日
Hi Aadithya,
Some suggestions.
Study and experiment with the full set of capabilities of the Delay block including
  • Initial condition as Input port
  • Enable port
  • External reset port
Put a copy of Detect Rise Positive block in your model. Then "Look Under Mask" by selecting the block and doing Control-U. This should give you some initial ideas on how to achieve your solution.
Your solution will need to be more complicated than Detect Rise Positive. You'll probably want to capture the last input value that produced a trigger using the Delay block. Then you'll compare if the current input is different from the last trigger by some threshold. If a change of 10 or more is what you want for a trigger, then that should be fairly straightforward. If you want the trigger condition to be about crossing exact multiples of 10, then that will require a little more manipulation such as rounding.
Pay special attention to what you want to happen at the very first time step, and after a reset. Resets can occur if your block is inside a resetable subsystem. Should your block always output true at first time step and after a reset, or? What value should be stored in the unit delay at first time step and after a reset? These are detailed design decisions you'll need to make.
Andy

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by