MATLAB Answers

Why does an if block only run once?

1 view (last 30 days)
Jon Emonson
Jon Emonson on 26 Oct 2016
Commented: Jon Emonson on 26 Oct 2016
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?

  0 Comments

Sign in to comment.

Accepted Answer

Steven Lord
Steven Lord on 26 Oct 2016
I think you want to use a Math Function block to compute the mod of your input.

  1 Comment

Jon Emonson
Jon Emonson on 26 Oct 2016
That's a winner. Thanks for the hint, a nice simple solution.

Sign in to comment.

More Answers (2)

Terek Li
Terek Li on 26 Oct 2016
'if' statement is not a loop, if you want to look it then use 'while'

  0 Comments

Sign in to comment.


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

  0 Comments

Sign in to comment.

Products


Translated by