- Initial condition as Input port
- Enable port
- External reset port
check if input data in simulink changes by a certain specific value
3 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Andy Bartlett
on 19 Apr 2022
Hi Aadithya,
Some suggestions.
Study and experiment with the full set of capabilities of the Delay block including
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
0 Comments
See Also
Categories
Find more on Event Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!