Why does an if block only run once?

조회 수: 5 (최근 30일)
Jon Emonson
Jon Emonson 2016년 10월 26일
댓글: Jon Emonson 2016년 10월 26일
I have an issue in Simulink where I have to condition an output signal which currently is a striaght line, but should reset to zero when it hits a multiple of 360 degrees. This has been done by taking the input and subtracting 360 if true, else it's a straight-through. I've already tried an if-else block and action subsystems, however that seems to only execute once (i.e. when the output reaches 360 for the first time, after that it continues past 360 until the simulation times out).
Any ideas?

채택된 답변

Steven Lord
Steven Lord 2016년 10월 26일
I think you want to use a Math Function block to compute the mod of your input.
  댓글 수: 1
Jon Emonson
Jon Emonson 2016년 10월 26일
That's a winner. Thanks for the hint, a nice simple solution.

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

추가 답변 (2개)

Terek Li
Terek Li 2016년 10월 26일
'if' statement is not a loop, if you want to look it then use 'while'

Jon Emonson
Jon Emonson 2016년 10월 26일
Well, any suggestions how to use a while loop to condition the input signal such that every n*360 to subtract n*360?

카테고리

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