Simulink bloc to check if a condition is true during a period of time

조회 수: 20 (최근 30일)
NeedsSupport
NeedsSupport 2013년 5월 7일
Hi everyone, I wish to thank you for your time. I need to create a Simulink block: the input of the block is x, the output is outp. the simulation time is 10 steps (the unit I use to express time is the step of the simulation time, not seconds or minutes). The Simulink block does the following: if (x<0.9 during 5 steps of simulation time) then outp=1; Although it looks very easy but I have no idea on how to check the time condition. Any help is welcome. Thank you very much.

답변 (2개)

Babak
Babak 2013년 5월 7일
You can use a "Weighted Sample Time" block to know what's the sampling time and an "If" block to create a condition.
If you only care about counting the sampling times passed, you can also use a "Counter Free-Running" block that starts counting from 0 as soon as the simulation starts.
When you open the Simulink Library Browser, search for these three blocks' names and use them to make your model.
  댓글 수: 1
Babak
Babak 2013년 5월 8일
in the weighted sample time, you can chose Ts only (or 1/Ts only) and u don't need an input. Output is not dependent on the input because the output is either Ts only (or 1/Ts only). But if you want to add something to Ts or multiply or divide,... you can use other options and it does the operation for you. Ts is the sampling time. I don't thin you need weighted sample time.. a counter works good enough for your case.

댓글을 달려면 로그인하십시오.


NeedsSupport
NeedsSupport 2013년 5월 8일
Thank you for your help. i just wonder what should be the input for the weighted sample time? a constant (=1) didn't work for me, and the clock didn't work either.

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by