在MATLAB 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-根据

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.