show Command Window Application Designer, How can I display the Command Windows within App Designer?

15 ビュー (過去 30 日間)
How can I display the Command Windows within App Designer?
I have a code that I am programming, I need it to be executable on another pc, for that I can use the compilation app or the disegner app. but I need everything that comes out in the windows command to appear in a window or be printed when executing the code, as if it were the matlab workspace

回答 (1 件)

prabhat kumar sharma
prabhat kumar sharma 2024 年 5 月 2 日
Hi David,
I understand you want to include the command window in the app designer application itself. In MATLAB App Designer, we cannot directly embed the Command Window within your app's GUI. However, you can simulate similar functionality by capturing output that would typically go to the Command Window and displaying it in a UI component, such as a TextArea. This approach requires redirecting or capturing the output from your functions and commands and then explicitly setting the text of the TextArea to display this output.
Here are the steps which you can follow:
1. Drag a TextArea component to your app's UI.
2.To capture output, you'll generally need to modify your functions or commands to return their output as strings, or you have to capture the output of built-in functions or commands that write to the Command Window.
For custom functions, modify them to return their output as a string or cell array of strings instead of displaying directly using disp or similar functions.
For capturing output from MATLAB functions or commands that write to the Command Window, you can use evalc. The evalc function captures the output of commands executed inside it. For example:
[T, result] = evalc('disp("Hello, World!")');
3. Display Output in TextArea
function myFunctionCallback(app, event)
% Example command
[T, result] = evalc('disp("Hello, World!")');
% Append the captured output to the TextArea
currentText = app.TextArea.Value;
app.TextArea.Value = [currentText; {result}];
end
You can use this workaround to get the desired functionality, I hope it helps!

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by