필터 지우기
필터 지우기

How do I get MatLab to respond to keyboard?

조회 수: 12 (최근 30일)
Emily Smith
Emily Smith 2016년 10월 19일
댓글: Walter Roberson 2016년 10월 21일
I would like to run some code if the letter "r" is pressed on the keyboard. How would I do this? And what syntax would be used? And should I store the code I would like to run in a separate editor?
Thank you!
  댓글 수: 1
Adam
Adam 2016년 10월 19일
Take a look at KeyPressFcn in Figure properties.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2016년 10월 19일
  댓글 수: 7
Emily Smith
Emily Smith 2016년 10월 20일
sorry for all the questions by the way, I'm new at this
Walter Roberson
Walter Roberson 2016년 10월 21일
In the editor for callbackfunction.m change the code to be
function callbackfunction(src, event)
if strcmp(event.Character, 'r')
imshow('TheImageToDisplay.jpg');
end
Then in the code that needs to tell MATLAB to allow that callback to be used, put in
set(gcf, 'Windowkeypressfcn', @callbackfunction)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Desktop에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by