필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Exchanging data between different GUI

조회 수: 1 (최근 30일)
Deyan
Deyan 2012년 7월 16일
마감: MATLAB Answer Bot 2021년 8월 20일
Dear all,
I am trying to use data between different GUI. First I tried with global variables, but it seems to be very dodgy. Hence I decided to use setappdata / getappdata. However, these define a value for an object within a GUI. How do I access the object from the other GUI, where I need the data?
Here is my example: in the 1st file, I have the callback function: setappdata(handles.fileTarget,'sim_path',dir_name)
an in the other, when I try: title = getappdata(handles.fileTarget,'sim_path')
I obv get an error because the handles.fileTarget is not present in this GUI. How do I call it?

답변 (1개)

Caleb
Caleb 2012년 7월 16일
If you set and get the app data from the root instead of from an individual GUI, all the others GUI figures should be able to see the information as well. In MATLAB, the root is designated by a 0. For example:
number = 10;
% Assigns the value of number, in this case 10, to a variable called count in the appdata of the root.
setappdata(0,'count',number)
% Gets the current value of count from the root's app data.
getappdata(0,'count')

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by