필터 지우기
필터 지우기

How to save the elapsed time to workspace when using GUI?

조회 수: 2 (최근 30일)
W Joey
W Joey 2015년 7월 26일
댓글: W Joey 2015년 7월 28일
Hello everyone, I have created a callback function of a button in GUI, now i want to record the elapsed time from the point of i click the button to the point a certain condition is met and save it in a cell(T0)in workspace. I added 'tic' in the callback function and 'toc' after the condition is met.
function pushbutton1_Callback(hObject, eventdata, handles)
tic;
if...
T0{t}=toc;
...
end
assignin('base','T0',T0)
The problem is that the whole process runs smoothly and no error occurred but there was no T0 in workspace. Anyone could help or give me some suggestions? Thanks in advance.
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2015년 7월 26일
W - put a break point at the line
assignin('base','T0',T0)
and re-run your code. When you press pushbutton1, the debugger will pause at this line. Look at T0 - has it been initialized (i.e. has the condition been met)? Then step over this line to see what happens. You may want to evaluate this line in the command window just to see what happens.
W Joey
W Joey 2015년 7월 28일
You are right. I try to assign T0 in command line and it shows Undefined function or variable 'T0'. Seems that there's something wrong with the 'if' condition.

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

답변 (1개)

Image Analyst
Image Analyst 2015년 7월 26일
I seriously doubt there is any need to save it to the base workspace. I never save anything to the base workspace - ever. There is just no need to.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by