惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google DeepMind News
Google DeepMind News
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
T
Tenable Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
W
WeLiveSecurity
D
DataBreaches.Net
Attack and Defense Labs
Attack and Defense Labs
H
Heimdal Security Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
AI
AI
P
Proofpoint News Feed
PCI Perspectives
PCI Perspectives
Schneier on Security
Schneier on Security
T
Threatpost
GbyAI
GbyAI
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
H
Help Net Security
F
Full Disclosure
T
Threat Research - Cisco Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
M
MIT News - Artificial intelligence
L
Lohrmann on Cybersecurity
Martin Fowler
Martin Fowler
博客园 - 【当耐特】
Y
Y Combinator Blog
腾讯CDC
The Hacker News
The Hacker News
博客园 - Franky
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园_首页
Simon Willison's Weblog
Simon Willison's Weblog
L
LINUX DO - 最新话题
Security Latest
Security Latest
Know Your Adversary
Know Your Adversary
Forbes - Security
Forbes - Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
SegmentFault 最新的问题
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
L
LangChain Blog
Vercel News
Vercel News
Cisco Talos Blog
Cisco Talos Blog
量子位
P
Proofpoint News Feed
H
Hacker News: Front Page
Help Net Security
Help Net Security
L
LINUX DO - 热门话题
Project Zero
Project Zero
C
Cisco Blogs

博客园 - febird

改进 GAE cpedialog 博客程序的一些细节 Python 格式化输出时间字符串函数 strftime 从IEEE802.1到IEEE802.22 CodeWarrior for Freescale S12 开发Tips - febird 第一个 Android 程序 [资料] IPv6主机地址 Web中使用MSCOMM32.OCX读写串口(2) Web中使用MSCOMM32.OCX读写串口 Matlab中Timer的使用 My Matlab Tips (Unfinished) Matlab中使用Plot函数动态画图方法总结 Matlab GUIDE使用总结--Matlab GUI界面 Matlab Deploy工具的使用--Matlab生成可执行文件 使用matlab作为图表绘制工具--Matlab使用入门 基于DE2 与Nios II的音频录放系统的设计-软件篇 基于DE2 与Nios II的音频录放系统的设计-系统篇 GMail今天更换外观了-支持主题 Google WebMaster网站验证错误(404返回成功)解决方法 Febird.co.cc 恢复正常访问
Matlab多窗口传值问题(GUI)
febird · 2008-12-20 · via 博客园 - febird

  1.直接传递
 

   当要在一个matlab中的.m文件打开一个新窗口时候,可以直接传递

   例如有两个窗口 A.fig/A.m 和 B.fig/B.m

   在 A.m中

   B(var1) ; 即可传入参数

  那么在B中这样获取即可:
 
  if  length(varargin)==1
  
     some_var= varargin{1};

  end

 2.通过output属传回

  在A.m中

  some_var=B(var1);

  也就是 B还需要返回值。

   那么在B中就需要设置handles的output值了

  function varargout = B_OutputFcn(hObject, eventdata, handles)

  varargout{1} = some_var_in_figure_B;

 3. 几个重要的函数

    1.getappdata(h,'Name'); 获取窗口句柄为h中的'Name'变量
    2.setappdata(h,'Name',value);设置窗口句柄为h中的'Name'变量为Value
    3.isappdata(h,'Name'); 判断h句柄下面有无‘Name’的变量
    4.rmappdata(h,'Name');删除h句柄下面‘Name’的变量

     5.guidata(h);  获取窗口句柄为h的 handles结构
     6.guidata(h,handles);  设置窗口句柄为h的handles结构为handles

     7.guihandles(h) 生成handles结构

   说明:
     关于appdata的几个函数是最基本的,每个figure都可以有几个很多appdata,setappdata(0,'Name',value) 当设置句柄为0时,表示整个Matlab共享的数据域,任何figure都可以访问。这也可以成为数据传递的另一种方式。

    hansles是我们在GUI的m文件经常看到的东西,为什么会有guidata呢?那是因为一个figure对象下面可能有很多其他的对象,例如 edit axes slider 等等,为了将这些东西组织起来供用户方便的访问,matlab特地的添加了这个数据结构,它包括改figure所有的控件。你可以直接访问  

  使用 guihandles(h) 可以生成 hanles结构,它包含 h 中的所有控件,其中h可以从fig文件load进来。

   guidata(h) 返回 matlab默认给这个 figure生成的 handles结构 。

   guidata(h,handles) 是修改 h (如果是一个figure) 或者 h 的父figure的handles值。

  它会不停的向上查找 h的parent ,知道为figure,然后便修改其handles值。

4.句柄概念

  个人认为,句柄就是相当于指针的意思,在Matlab中,每一个GUI对象都有一个handle,他们都是一些小数或者整数,Matlab能够保证这些数字不重复,因此通过这个句柄就可以访问或者修改你的对象。

 通过传递 句柄的方式可以修改传递的值的内容,而传递变量就做不到,这点和C语言的指针类似。