Importing values from one window to another in MATLAB GUI

南笙酒味 提交于 2019-12-13 06:57:52

问题


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();

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);

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


回答1:


  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);

  2. 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.




回答2:


You can store data in the GUI UserData property:

set(handletoFigure,'UserData',Values);

when you open the other GUI you retrieve the info:

Values = get(handletoFigure,'UserData);

Is there a reason why you don't want to use setappdata/getappdata?

As for your 2nd question I don't know sorry. I guess it's the RAM though



来源:https://stackoverflow.com/questions/25017784/importing-values-from-one-window-to-another-in-matlab-gui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!