필터 지우기
필터 지우기

How can I match a clock time to a variable?

조회 수: 1 (최근 30일)
Hamish Laing
Hamish Laing 2013년 6월 21일
Hi there,
I am creating a GUI on matlab and want to output what is being clicked in real time. When a button is pressed on my GUI I out put a string variable 'Yes' or 'No'. I wish to be able to place the results of the button on a table. One column will have the button response 'Yes' or 'No' and the second column will have the time that the button was pressed.
For example
Response Time; Yes 1.30; No 5.13; Yes 9.48;
Is this possible? If so how would I go about it?
  댓글 수: 1
Daniel Shub
Daniel Shub 2013년 6월 21일
Do you want the time the button was pressed or when the callback was processed?

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

답변 (2개)

Vishal Rane
Vishal Rane 2013년 6월 21일
In the callback for the button being clicked, update the data on the uitable using,
TableData = get( handles.uitabletag, 'Data') % Fetch existing data
TableData = [ TableData; {'Yes',datestr(clock)} % update the data
set( handles.uitabletag, 'Data', TableData ) % upload updated data to the table
  댓글 수: 1
Daniel Shub
Daniel Shub 2013년 6월 21일
This will place the time the callback was executed in TableData, while often similar, this is not the time the button was pressed (nor released), but rather some indeterminate time after the button was pressed and MATLAB got around to processing the event queue.

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


Iain
Iain 2013년 6월 21일
I'm not sure, but it you change the callback to have "now" as the eventdata, it should execute when the callback is called. Whether or not that interrupts the event queue to take its value is I don't know.

카테고리

Help CenterFile Exchange에서 Clocks and Timers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by