필터 지우기
필터 지우기

simulink, switch problem

조회 수: 6 (최근 30일)
aft
aft 2011년 7월 30일
답변: Josco Kester 2019년 1월 10일
Hi, a little problem i m facing while using simulink. my time step is of 0.025s and i have a switch which says enter into my controller when t > 0.075, meaning that at t=0.1s onwards. Simulink does the simulations at the time values 0, 0.025, 0.05, but then 0.07500000000001 and enters into my controller. WHY ??? I am having an algebraic loop in my system, does it have anything to do with that ? but if i change my switch condition to 0.1 instead of 0.075, no problem.
thanx in advance,
khawaja

답변 (3개)

Fangjun Jiang
Fangjun Jiang 2011년 7월 30일
I am not sure. Maybe you don't need to care about it. It might be floating point number precision thing, such as:
>> (0.025*3)==0.075
ans =
0
>> (0.025*4)==0.1
ans =
1

Prashant Srivastava
Prashant Srivastava 2011년 7월 30일
For algebraic loops error, you can connect a unit delay block between your input and the output(that you're reusing).

Josco Kester
Josco Kester 2019년 1월 10일
@aft, your problem exists because the duration of the time steps in Simulink unfortunately is NOT exact. This is caused by floating point round-off (see https://blogs.mathworks.com/simulink/2012/02/09/using-discrete-data-as-an-input-to-your-simulink-model/ ).
A work around in your case could be to use t > 0.08 as switch criterium. In any case avoid any exact criterium such as t > n*0.025. How that criterium behaves is NOT determined, because of the floating point round-off error. The criterium t > 0.1 could also give a problem next time...

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by