问题描述
假设我在窗口中有一个按钮,当我单击它时,将出现一个新窗口.我用以下语法称呼此窗口(名称为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();
我想从主窗口向此新窗口插入一些值.我知道可以为此目的使用setappdata
或getappdata
,但是还有另一种方法吗?例如这样的语法:
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);
另一个问题.当我们使用setappdata
或getappdata
时,MATLAB在何处存储此数据?在RAM或硬盘驱动器中?
Another question. When we use setappdata
or getappdata
, where MATLAB stores this data? In the RAM or Hard drive?
推荐答案
-
是的,您可以使用
My_New_Window(Values);
.例如,在GUIDE中,无论传递给GUI的任何参数,都可以使用OpeningFcn
的输入在OpeningFcn
中进行处理.只需将varargin
分配给您的handles
结构并使用guidata(hObject, handles);
Yes, you can use
My_New_Window(Values);
For example, in GUIDE, whatever parameters you pass to your GUI, you can handle in theOpeningFcn
using itsvarargin
input. Simply assignvarargin
to yourhandles
structure and useguidata(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中将值从一个窗口导入到另一个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!