How I pass variable (number) from separate m-file to GUI edit text box?

1 回表示 (過去 30 日間)
Teemu Juujärvi
Teemu Juujärvi 2015 年 8 月 27 日
編集済み: Jeffrey Alido 2017 年 7 月 28 日
Hi,
I have separate m-file which generates numeric value once a second and I want to pass this value to GUI once a second. How can I pass this variable to GUI from separate m-file and update it at second intervals?
I have tried many things but haven't succeed yet. Please help if you can.
Teemu

採用された回答

Rutuja Shirali
Rutuja Shirali 2015 年 8 月 31 日
編集済み: Rutuja Shirali 2015 年 8 月 31 日
I believe that you have a m-file which is a function having either a timer function or a loop to generate the numeric value. You will need to pass the handle to the GUI to this function in the m-file and then set the value of the text box.
  1. Set the 'Tag' property in the GUI code for the text box So that we can identify the text box.
  2. Pass the handle to the GUI to your function which generates the numeric value
  3. Access the text box using the "findobj" function in your function. Something like this tb = findobj(figHandle,'Tag', tagvalue)
  4. Set the text to the numeric value. Something like this set(tb,'String',numeric_value)
I hope this helps with your issue. If this is not what you are expecting I would suggest contacting MathWorks Technical Support with more clarification on your workflow.
-Rutuja
  1 件のコメント
Jeffrey Alido
Jeffrey Alido 2017 年 7 月 28 日
編集済み: Jeffrey Alido 2017 年 7 月 28 日
Hi Rutuja,
Can you help clarify the steps for me even further? I'm a beginner and I'd like to do this same thing.
My .m timer function is:
function timer
for i = 1:15
clc;
i;
pause(1)
end
And the tag for my textbox is text2. I'd like to push a pushbutton and have the timer show up on the textbox.
Thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Report Generator についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by