what does this error with tic\toc means?

i have this problem - matlab tells me I have an error while running-
Error using toc
You must call TIC without an output argument before calling TOC without an
input argument.
Error in hand_rotation2/youPress (line 126)
c = toc;
Error while evaluating figure KeyPressFcn
what does it mean, and how can I fix it?

 採用された回答

Wayne King
Wayne King 2012 年 10 月 15 日
編集済み: Wayne King 2012 年 10 月 15 日

1 投票

It means to use toc, you have to call tic first somewhere
tic;
for ii = 1:10
x(ii) = ii+1;
end
y = toc;
If you use toc by itself, it must have been preceded by a tic command sometime during the current session, then it gives the time since the most recent tic command. In this latter case, that is probably not what you want.

2 件のコメント

alex
alex 2012 年 10 月 15 日
well, then I don't understand I I'm getting this error- I have a timer that starts with tic (in the StartFcn) and the user will press the keys only after tic began, and there is the toc..
those are my functions-
function youPress(~,eventdata)
if eventdata.Key== 'i'
c = toc;
anscell{ii,2}=c;
anscell{ii,3}='i';
stop(t)
elseif eventdata.Key== 'e'
c = toc;
anscell{ii,2}=c;
anscell{ii,3}='e';
stop(t)
end
end
% code
end
function timer_started(~,~)
tic
end
function timer_stop(~,~)
toc
set(a7,'Visible','on');
ii=ii+1;
if ii<10
START_TIMER;
else
set(a7,'Visible','off');
set(a8,'Visible','on');
set(a9,'Visible','on');
end
end
function START_TIMER(~,~)
set(a7,'Visible','on');
pause(plus_time);
b=unidrnd(size(imcell,2));
anscell{ii,2}=imcell{2,b};
set(a7,'Visible','off');
axes('Position',[.35 .3 .3 .3]);
image(imcell{1,b});
start(t);
end
Image Analyst
Image Analyst 2012 年 10 月 15 日
Maybe the tic doesn't survive once you've exited the function.

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

その他の回答 (1 件)

Nicolas Rodriguez
Nicolas Rodriguez 2016 年 1 月 8 日

0 投票

I have the same problem. My code runs as long as I keep matlab open. Once I close it, it won't let me run it and show me error

1 件のコメント

Walter Roberson
Walter Roberson 2016 年 1 月 8 日
Which MATLAB version are you using?

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

カテゴリ

ヘルプ センター および File ExchangeProfile and Improve Performance についてさらに検索

質問済み:

2012 年 10 月 15 日

コメント済み:

2016 年 1 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by