特定のキーを押すまでの時間を記録する
Show older comments
現在、動画中の動物が、特定の行動をした時間について記録することを考えております。
tic toc 関数、並びにif構文を用いて、「特定のキー(例えばEnter)を押した際に、マトリックスに特定のキーを押すまでの時間を記録する」事を試してみましたが、上手くいきません。
もし良ければ、コードの提案等をしていただけますと幸いです。
Answers (1)
Shunichi Kusano
on 27 Mar 2023
input関数を使うとキーボードからの入力待ちになり、かつ何ボタンを押したかを記録することができます。
例えばEnterなら[](空)になりますので、下のようになります。
timeVal = tic; % 測定開始
x = input("press Enter to record elapsed time."); % コマンドウィンドウにプロンプトを出して指示待ち
if isempty(x) % もし押されたのがEnterであれば
elapsed_time = toc(timeVal) % 経過時間を保存
end
参考にしていただければ幸いです。
Categories
Find more on Video Formats and Interfaces in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!