If you try to run the fllowing program,how long would it take?

2 ビュー (過去 30 日間)
marina
marina 2014 年 7 月 2 日
コメント済み: marina 2014 年 7 月 3 日
c=clock
d=c(3)
while d==c(3)
c=clock;
end
what's the meaning of"if you insist on running it,change both 3's to 5's "?
this code is copy from P44, Experiments with MATLAB,Cleve Moler

採用された回答

Star Strider
Star Strider 2014 年 7 月 2 日
My guess would be until local midnight the day the program started.
  3 件のコメント
Star Strider
Star Strider 2014 年 7 月 2 日
編集済み: Star Strider 2014 年 7 月 2 日
Because if you do:
c = clock
the result (just now, GMT-6) is:
c =
2014 7 1 21 22 22.94
The third element is the day ( 1 here ), so since the loop continuously polls the clock function, that element will change to 2 at local midnight, d will no longer equal c(3) and the loop will stop.
If you change the 3’s to 5’s, the element changes to the minute element, and the program will run for at most one minute and then stop.
marina
marina 2014 年 7 月 3 日
thanks!:)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by