v-crn Code Log

主に備忘録

Octave 5.1.0でpauseの挙動がおかしい

CouseraのStanford University Machine Learningクラス2週目の課題ex1「2.1 Plotting the Data」において、説明に従ってplotData.mを編集し、ex1を実行すると、Enterキーを押してもpauseのまま動かなくなる事案に遭遇した。

Running warmUpExercise ... 
5x5 Identity Matrix: 
ans =

Diagonal Matrix

   1   0   0   0   0
   0   1   0   0   0
   0   0   1   0   0
   0   0   0   1   0
   0   0   0   0   1

Program paused. Press enter to continue.

調べてみたところ、どうやらOctave 5.1.0ではpause関数にバグあることに原因があるようだ。

下記の記事を参考に、新たにpause関数を定義することで解決した。

octave pause; not working properly. Forces to ctrl+c :( : octave

ex1.mの適当な箇所に次の内容を追記。

function pause
  input('','s');
end

これでEnterキーを押すごとに処理が進行する。