フィルターのクリア

Press a key to stop the program?

9 ビュー (過去 30 日間)
keith lin
keith lin 2014 年 1 月 28 日
コメント済み: keith lin 2014 年 1 月 29 日
function funny_func()
while true
printf("hello world");
pause(1);
end
end
So basically I need to edit my code so that I can manually stop the code.
For example >>> funny_func() hello world hello world hello world
(Then I press "j" it has to be specially "j" in the keyboard") Then the program will stop. Anyone know how to do it? Thanks

採用された回答

Amit
Amit 2014 年 1 月 28 日
I think you can use this function from fileexchange: http://www.mathworks.com/matlabcentral/fileexchange/8297-getkeywait
  9 件のコメント
Amit
Amit 2014 年 1 月 28 日
Keith, I understand that you dont wanna touch pause. I gave the solution accordingly. Instead of every pause, you can use getkeywait(p) which is equivalent of pause(p) but also give you another feature. Control via keyboard.
In the end, its your choice. I dont have to convince you as I am not selling anything to you. I can say 100 times that pause(p) and getkeywait(p) are similar, except that pause blindly waits for p secs while getkeywait will wait for p second but will take responses.
keith lin
keith lin 2014 年 1 月 29 日
Oh I see, I am just a bit confuse with the function. Thanks!!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by