GUI中将值从一个窗口导入到另一个窗口

GUI中将值从一个窗口导入到另一个窗口

本文介绍了在MATLAB GUI中将值从一个窗口导入到另一个窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在窗口中有一个按钮,当我单击它时,将出现一个新窗口.我用以下语法称呼此窗口(名称为My_New_Window):

Suppose that I have a button in a window that when I click on it a new window will appear. I call this window (with the name of My_New_Window) with this syntax:

My_New_Window();

我想从主窗口向此新窗口插入一些值.我知道可以为此目的使用setappdatagetappdata,但是还有另一种方法吗?例如这样的语法:

I want to insert some values to this new window from main window. I know that I can use setappdata or getappdata for this purpose but Is there another way to this? For example like this syntax:

My_New_Window(Values);

另一个问题.当我们使用setappdatagetappdata时,MATLAB在何处存储此数据?在RAM或硬盘驱动器中?

Another question. When we use setappdata or getappdata, where MATLAB stores this data? In the RAM or Hard drive?

推荐答案

  1. 是的,您可以使用My_New_Window(Values);.例如,在GUIDE中,无论传递给GUI的任何参数,都可以使用OpeningFcn的输入在OpeningFcn中进行处理.只需将varargin分配给您的handles结构并使用guidata(hObject, handles);

  1. Yes, you can use My_New_Window(Values); For example, in GUIDE, whatever parameters you pass to your GUI, you can handle in the OpeningFcn using its varargin input. Simply assign varargin to your handles structure and use guidata(hObject, handles);

关于setappdata-根据在对象"内部.由于对象驻留在内存中,因此可以安全地将其确实保存在RAM中.

Regarding setappdata - according to this book the data is stored inside an "object". Since objects reside in memory, it is safe to assume that it is indeed kept in RAM.

这篇关于在MATLAB GUI中将值从一个窗口导入到另一个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!