필터 지우기
필터 지우기

How can I update a text in app designer when Matlab script is running?

조회 수: 35 (최근 30일)
Thomas Firsich
Thomas Firsich 2018년 10월 19일
답변: Siddharth Nimbajirao Deore 2019년 8월 28일
I created a GUI in app designer that a user chooses variables and then it will run the function in Matlab. For this, I tried to use the diary function to write to a file what is output to the command window that would then use drawnow to send to the GUI. I am having problems because I am not sure how to update the label in the GUI with the text output from my function. Attached is the code for trying to set the label and the error message that is given by app designer.
if options.gui % stop coping outputs to command window and send to GUI
diary off;
output = fileread('diary');
set(app.Label,'string',output); % fill in 'textbox_handle' with the actual handle for the textbox
drawnow;
end
  • Undefined variable "app" or class "app.Label".*
-Thanks
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 10월 19일
Note that reading from the diary is not well defined unless you turn the diary off first.
You should probably be adjusting your code so that the output is saved instead of being displayed so that diary is not needed. If that is not practical, then consider using evalc() to run the functions to capture the output.

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

답변 (2개)

Siddharth Nimbajirao Deore
Siddharth Nimbajirao Deore 2019년 8월 28일
call pause for millisecods before your function to render UI elements
if options.gui % stop coping outputs to command window and send to GUI
diary off;
output = fileread('diary');
set(app.Label,'string',output); % fill in 'textbox_handle' with the actual handle for the textbox
pause(0.00000001);
drawnow;
end

Batbayar Temuujin
Batbayar Temuujin 2018년 10월 20일
textLabel = sprintf('%s', output);
app.Label.Text = textLabel;

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by