简体   繁体   English

如何使用Matlab App Designer显示数据/信息?

[英]How do I display data/information with Matlab App Designer?

I would like to display some information to the user via Matlab App Designer's GUI. 我想通过Matlab App Designer的GUI向用户显示一些信息。 I am new to this program and can't seem to find a widget that provides what I feel should be a simple function. 我是该程序的新手,似乎找不到提供我认为应该是简单功能的小部件。 Am I missing something? 我想念什么吗? Examples would include showing the user: 示例包括向用户显示:

  1. The path of the file that he/she selected 他/她选择的文件的路径
  2. Errors such as "No files detected" that are printed in a Matlab script called on by the GUI code. 错误,例如在GUI代码调用的Matlab脚本中打印的“未检测到文件”。
  3. Other print statements in code such as "Done!", etc that will inform the user when a process is complete. 其他打印语句,例如“ Done!”等,将在处理完成时通知用户。

Is there a way to capture the output in the Matlab command line and report these in a window of some sort in the GUI? 有没有办法在Matlab命令行中捕获输出并在GUI的某种窗口中报告这些输出? Thanks in advance! 提前致谢!

You can use a TextArea to display information for the user. 您可以使用TextArea为用户显示信息。 Here's how I made a simple example: 这是我做的一个简单示例:

  1. Drag a button to the app in design view. 将一个按钮拖到设计视图中的应用程序。
  2. Drag in a text area also. 也拖动一个文本区域。 I changed the label to Feedback. 我将标签更改为“反馈”。
  3. Select the button and use the Callbacks tab in the bottom right of app designer to add a callback with the default name it gives you. 选择该按钮,然后使用应用程序设计器右下方的“回调”选项卡添加具有其默认名称的回调。
  4. Edit the callback to contain 编辑回调以包含

      answer = 'what your want to display'; app.FeedbackTextArea.Value = answer; 

When you push the button the text area gets filled. 当您按下按钮时,文本区域将被填充。 In your code, instead of just setting 'answer' to some string, set a variable using whatever code is dealing with your user's information. 在您的代码中,不仅仅是将“ answer”设置为某个字符串,还可以使用处理用户信息的任何代码来设置变量。 The key is to store what you want the user to see in a variable and then assign that to the "Value" parameter of the text area or other widget where you want them to see the results. 关键是将您希望用户看到的内容存储在变量中,然后将其分配给您希望用户看到结果的文本区域或其他小部件的“ Value”参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM