How do you get text field in App designer to out strings or numbers from a code that executes when a button is pressed

조회 수: 12 (최근 30일)
Please see image. Pressing the start button, executes the code as indended and generates the plots as it should. My goal is to also display the the texts in code below as well. But I'm not able to. These are the same texts that would be displayed in the command window if the code were to be executed normally in Matlab.
I've tried using the 'app.Output.x' (where Output is what the text field is named as) under the 'START' button callback function. I'm not sure what to replace 'x' with or if this is the right callout at all to get it do what I want or if it should be under the start button callback.
Thanks in advance
I
  댓글 수: 2
dpb
dpb 2025년 4월 1일
An app doesn't have a console so the output of disp goes to the command window...you need a text box in the app to which to output stuff to the user -- of, if it is temporary, a message dialog popup...
jchris14
jchris14 2025년 4월 1일
sorry for the confusion, but the app does have a text box. That's titled as "what's happening". Unless you're talking about something else?

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

답변 (1개)

Walter Roberson
Walter Roberson 2025년 4월 1일
If app.Output is a uitextarea() then
str = evalc("disp('first string'); disp('second string'); disp('third string');";
app.Output.Value = str;
fprintf('%s\n', str);
But you might as well just do
str = ["first string"; "second string"; "third string"];
app.Output.Value = str;
fprintf('%s\n', str);
If you were to insist that the "disp" be unchanged, then the way to handle this would be to "diary" so that the result of the disp() are written to a file as well as appearing on the screen, and then close the diary and readlines the text, and set app.Output.Value to the text.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by