Accessing a variable used in a botton from another button

Hi , I am using matlab R2013a
I declared a variable name as wav in a button's callback function as shown below
function record_Callback(hObject, eventdata, handles)
wav=wavrecord(10*8000,8000);
Now, I want to access this variable from the callback function of another button as shown below
function play_Callback(hObject, eventdata, handles) sound(wav);
Any easy way to do it?

 採用された回答

Jan
Jan 2015 年 4 月 27 日
編集済み: Jan 2015 年 4 月 27 日

0 投票

This topic is dicussed frequently and you can find it e.g. by searching in this forum for "share variable between callbacks". See e.g. http://www.mathworks.com/matlabcentral/answers/146260-how-to-share-variables-between-two-gui-callbacks
function record_Callback(hObject, eventdata, handles)
handles = guidata(hObject);
handles.wav = wavrecord(10*8000,8000);
guidata(hObject, handles);
function play_Callback(hObject, eventdata, handles)
handles = guidata(hObject);
sound(handles.wav);

1 件のコメント

Talha Khan
Talha Khan 2015 年 4 月 27 日
Thanks a lot it is exactly what i want to do,

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

その他の回答 (0 件)

カテゴリ

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

タグ

質問済み:

2015 年 4 月 27 日

コメント済み:

2015 年 4 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by