global variable not working in all fonctions.

Hello everyone, I have a global variable which is not always well evaluated in the subfonctions that I have. in the main I 'm creating a GUI with buttons etc...and I when I click on the buttons I call the subfunctions (event).
in the main functions the global variable = a char
When I call the first time a subfunction by pushing a button, the global receive the same char. And if I click in another Button (I call another function), in the declaration the global variable became a double empty.

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 7 月 18 日
編集済み: Walter Roberson 2012 年 7 月 20 日

1 投票

%have you set those variables Global in all subfunction that use those variables?
%instead using global variables, why don't you save your variable "v" in any of your object "exemple: %object1"
set(handles.object1,'Userdata',v) %v can be array, string, ....
%to get your variable ue
get(handles.object1,'Userdata')

2 件のコメント

tayeb
tayeb 2012 年 7 月 20 日
thank you abdelmalek.
Jan
Jan 2012 年 7 月 20 日
Instead of using the UserData, you can store the value inside the handles struct duirectly also. See "help guidata".

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

質問済み:

2012 年 7 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by