필터 지우기
필터 지우기

Info

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

Sharing Three Dimensional Array Variable Among GUIs

조회 수: 2 (최근 30일)
ElevenFourth
ElevenFourth 2013년 4월 4일
마감: MATLAB Answer Bot 2021년 8월 20일
Hello everyone !
I am really new to matlab, and I am wondering if I could share a three dimensional array variable among GUIs.
I have tried using global variables. And I have typed the global variable declaration in every function/callbacks. But it doesn't work, it keeps giving an empty variable.
I prefer using a global variable. Any idea how to do the trick?
Please help me !
Thanks in advance
  댓글 수: 2
ChristianW
ChristianW 2013년 4월 4일
Can you specify your GUIs. Do you have several figures with ui-objects or only 1 figure? Are your GUIs programmed or are they GUIDE GUIs?
ElevenFourth
ElevenFourth 2013년 4월 4일
I have several figures. But even when I tried to combine 2 callbacks in 1 figure with global variable for the 3 dimensional variable, the variable would be empty.
It is guide GUIs.

답변 (2개)

ChristianW
ChristianW 2013년 4월 5일
In a GUIDE its provided to use the handles structure. But, using global does also work.
You need to declare the variable as global in every function (in which you use the variable). Global variables get a cyan color in code (at standard color-preferences). If you allready have done that, show the code line that assigns your variable.
The variable dimension is irrelevant in this regard.
  댓글 수: 3
ElevenFourth
ElevenFourth 2013년 4월 5일
편집: ElevenFourth 2013년 4월 5일
I found out something new.
Maybe it is because I use the following code :
clearvars -global poro_data;
So in general my code would be like this :
function pushbutton_OK_Callback(hObject, eventdata, handles)
global poro_data
.
.
.
clearvars -global poro_data;
for i=1:num_lay
poro_data(:,:,i)=xlsread(poro_browse,i);
end
I need to use the variable several times, if I want to use different excel files. And each excel file has its own matrix size. If I don't clear the variable first, the dimension would overlap and would mismatch.
But when I write the previous clearvars code, then the variable would be cleared in other functions.
Does anyone have a suggestion what to do?
ChristianW
ChristianW 2013년 4월 5일
Try to use empty initiate instead of clearvars.
poro_data = [];
Now to your empty output. The _OutputFcn will be executed directly after the _OpeningFcn. You need to tell your GUI to wait with the uiwait(handles.figure1); command at the end of the _OpeningFcn. To resume create a button or something with uiresume(handles.figure1) as callback.

Jan
Jan 2013년 4월 5일
If you want to learn somtheing about sharing data between GUIs, it would be a gooid strategy to search in the forum for "sharing data". You find a large number of related questions with solutions.

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

Community Treasure Hunt

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

Start Hunting!

Translated by