How to prevent the function within a Timer to keep displaying the answer in Command Windows?

Hi ALl
My code is shown as below
set(handles.edit3,'String',num2str(MyFuc(Input)));
tmr=timer('Period',10,'ExecutionMode','FixedRate',...
'TimerFcn',num2str(MyFuc(Input)));
start(tmr); % Start the timer object.
function Output=MyFuc(Input)
Output=Input*3;
end
Matlab's command window keeps display the answer from MyFuc. Anyone knows how can I stop command window displaying it?
Many Thanks,

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 4 日
編集済み: Azzi Abdelmalek 2013 年 2 月 4 日
Try
a=MyFuc(Input);
set(handles.edit3,'String',num2str(a));
tmr=timer('Period',10,'ExecutionMode','FixedRate',...
'TimerFcn',);
start(tmr); % Start the timer object.

7 件のコメント

Zheng
Zheng 2013 年 2 月 4 日
thanks, but it doesn't work.
What did you get when you type in matlab command
a=MyFuc(Input);
Zheng
Zheng 2013 年 2 月 4 日
I tried this one 'a=MyFuc(Input);' in command window. the answer doesn't display in the window. However, the answer automatically displays when I run it in a Timer.
Maybe you did not use the edited answer
a=MyFuc(Input);
set(handles.edit3,'String',num2str(a));
Zheng
Zheng 2013 年 2 月 4 日
I used it as well. It still keeps displaying. @_@
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 4 日
編集済み: Azzi Abdelmalek 2013 年 2 月 4 日
This is not displayed by MyFunc like you said in your question
Zheng
Zheng 2013 年 2 月 4 日
the answer is displayed only when the Timer is running. @_@

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

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

質問済み:

2013 年 2 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by