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!