필터 지우기
필터 지우기

Info

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

Question about preserving variables into GUI

조회 수: 1 (최근 30일)
Brian
Brian 2012년 8월 5일
마감: MATLAB Answer Bot 2021년 8월 20일
Hello, thanks for reading this,
I have a question about a GUI I set up.
Right now, I have a main.m file that first calls a function where I set up variables so I can put them into a workspace, then I call a GUI so I can manipulate the data and display it. So, my m file looks a bit like:
create_data
create_gui
If I manually call the create_data m file within the callback function of the GUI element I want, I can get the result I want, but I don't want to continually call the element, as it wastes memory and cpu time.
Any ideas?
Edit: I tried putting my variables one by one as global variables in my main.m file, but they still couldn't be accessed in my GUI file unless I called the file in the GUI function.

답변 (1개)

Seyhan Emre Gorucu
Seyhan Emre Gorucu 2012년 8월 6일
It might be more helpful if you write a simple example.
  댓글 수: 2
Brian
Brian 2012년 8월 6일
I've been screwing around with this for awhile, and something I ended up doing was creating a uitable from a workspace variable. The data will be forever constant, so I thought I might as well do it in this case.
After I did this, I just got the data from the uitable in callback functions and I got it to work. So, I guess in the end, I just went with the easiest approach, if not the most robust.
What I was trying to do was take data from a m file and put it into the workspace. Once the variables were in the workspace, I wanted to use those variables in individual callback functions without having to constantly recall the m file that created the variables.
Seyhan Emre Gorucu
Seyhan Emre Gorucu 2012년 8월 6일
편집: Seyhan Emre Gorucu 2012년 8월 6일
Well you can try this.
a=3;
save('data.mat','a')
This saves your data into .mat file at the same folder. You can upload it back at the function by:
load('data.mat')
Now the data is visible inside the function.

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by