Simulink: How to hold a if conditional over a period of time
26 次查看(过去 30 天)
显示 更早的评论
I am building a hybrid system where the engine load is modeled by Simulink, I need to stablish load given battery's State of Charge (SOC). My idea is to start with a percent load lest say 75% and have some kind of control that regulates by load given SOC. Lets say if SOC >80% for 10 seconds then lower engine percent load to 70%. How can I take that 10 second time sample and store it ?
Thanks
0 个评论
回答(1 个)
Arthi Sathyamurthi
2021-3-24
For an easy solution you can use Stateflow and create two states OFF and ON. Get the input SOC and check if it is greater than 80%. If so change the state to ON and run it for 10 iterations by using the ‘during’ function and then store the value by sending it back to Simulink and saving it as a workspace or a local variable. Stateflow also allows you to several condition statements. In case you are new to Stateflow you can take a look at this link.
If you want to use only Simulink then you can try using enabled subsystem block to enable the block for particular amount of time by sending square waveform for the particular duration of time you want and inside the subsystem create a output block and store the variable. But make sure to reset the signal and start over every time the defined seconds have crossed and the simulation comes out of the subsystem. You can also look at other subsystemsblock if it would suit your application.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!