フィルターのクリア

How can I update the results from a Timer to a text box every 5 second?

1 回表示 (過去 30 日間)
Zheng
Zheng 2013 年 2 月 4 日
My codes are shown as below:
TimeSpan = str2double(get(handles.edit1,'String'));
Parameter = str2double(get(handles.edit2,'String'));
My function is
funcion Output=MyFuc(Parameter)
Output=sin(Parameter);
end
How can I show 'Output' in textbox ('edit3') every 5 seconds (let's say TimeSpan=5);
So many thanks. I've been working on this for 2 days. Still cannot find correct answer....
Many thanks to everyone helping me.

採用された回答

Sean de Wolski
Sean de Wolski 2013 年 2 月 4 日
h = uicontrol('Units','Normalized','FontSize',15,'Position',[0.1 0.1 0.8 0.8],...
'Style','Text');
drawnow;
T = timer('Period',5,'StartDelay',0,'TimerFcn',@(src,evt)set(h,'String',evalc('why')),...
'ExecutionMode','FixedRate');
start(T)
  3 件のコメント
Matt Tearle
Matt Tearle 2013 年 2 月 4 日
What's missing from what Sean gave? Your timer callback function will have to be something like this:
@(~,~) set(handles.edit3,'String',num2str(MyFuc(str2double(get(handles.edit2,'String')))))
Each time this is called, it reads the value in edit2, passes that to your function, and sets the value in edit3 to be the result.
Zheng
Zheng 2013 年 2 月 4 日
it works now. Thank you very much... :-)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by