How to pause the clock while the simulation continues to run?

1 回表示 (過去 30 日間)
Sujan Dinesh
Sujan Dinesh 2016 年 9 月 29 日
コメント済み: Walter Roberson 2016 年 9 月 30 日
I have a model in which I have to compute the distance travelled for a constant speed over the simulation time. However the vehicle makes a number of stops in between during which I do not want the distance to calculate.
Is there a way to pause the clock(input) during these breaks so that I can get the exact distance travelled? The breaks made is given by a binary signal in which (1) is vehicle in running condition and (0) is vehicle in static condition.
My apologies if something similar has been discussed before, however I could not find anything online.
Thanks in advance!

採用された回答

Walter Roberson
Walter Roberson 2016 年 9 月 29 日
integrate the product of the binary signal and the distance measure. Any time the binary signal is stopped the product will be 0 which will not contribute to the total.
Or if the speed is constant, then integrate the binary signal, and multiply the integral by the constant speed to find the distance traveled.
  2 件のコメント
Sujan Dinesh
Sujan Dinesh 2016 年 9 月 29 日
編集済み: Sujan Dinesh 2016 年 9 月 29 日
The second solution worked, thanks!
If you don't mind, could you please explain what the integrate operator did to the binary signal and how come I didn't need to use time as an input to calculate my distance (constant speed)?
Walter Roberson
Walter Roberson 2016 年 9 月 30 日
The situation is like integral of 1 from 0 to t, which is going to return t even though t does not appear in the expression being integrated. Each timeslice of width timestep in which the binary signal is on is going to contribute timestep to the output, and each timeslice of width timestep in which the binary signal is off is going to contribute 0 to the output. That is going to give you timestep times (number of times it was on) as the total. If for example the timestep were 1 second, then the total would be the number of seconds spent traveling.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeClocks and Timers についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by