I need to use output from first function as input to second function (callback). This is not a problem if I don't close the GUI but I want to use first callback, save value, close GUI and then open GUI again and use that value in second function. I hope you guys understand.
I tried to use CloseRequestFcn and OpeningFcn with setappdata/getappdata or save/load but either this can't be done or I'm doing something wrong.
I had few different errors like "Reference to non-existent field " or similar but still stuck.
答案 0 :(得分:0)
我看到两个选项:
global
将变量声明为全局变量。按“保存”按钮和/或关闭GUI时写入此变量。然后在打开GUI和/或按下“加载”按钮时从全局读取。save
和load
函数将Matlab变量存储和检索到文件中。请参阅Matlab文档,了解如何仅存储特定变量。全局变量示例:
global testvar
if isempty(testvar)
testvar = 0;
end
disp(datestr(now))
disp(testvar)
testvar = testvar + 1;
文件示例:
if exist('testfile.mat', 'file')
load('testfile', 'testvar')
else
testvar = 0;
end
disp(datestr(now))
disp(testvar)
testvar = testvar + 1;
save('testfile', 'testvar')