how to create global variables for gui created using guide

when I create a gui using guide, the generated code is basically a series of non-nested functions, starting with intialization functions, followed by call backs for my gui elements. I need all these functions to operate on a set of global variables; but I cannot define anything before the first function(or it errors out "Function definitions are not permitted in this context"). How am I supposed to do this?

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 12 月 9 日
編集済み: Azzi Abdelmalek 2012 年 12 月 9 日

0 投票

If you want te handle data in your functions use guidata, or just save your data in Userdata of any object.
help guidata
A
A 2012 年 12 月 9 日

0 投票

I would rather use nested functions. According to "Data Management in a GUIDE gui" document, it is possible to "nest the GUI callbacks and utility functions at a level below the initialization"; However I'm not quite sure what that means.

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

質問済み:

A
A
2012 年 12 月 9 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by