【发布时间】:2023-02-07 03:17:28
【问题描述】:
我正在尝试创建一个 MATLAB 应用程序,将特定字段保存在 .mat 文件中并允许自定义命名。保存似乎有效,但尝试加载不会导致任何改变。 任何帮助,将不胜感激
function SaveButtonPushed(app, event) % Saving element
props = properties(app);
lp = length(props);
values = cell(1,lp);
visibilities = cell(1,lp);
for i = 1:lp
propName = props{1};
property = app.(propName);
if isprop(property, 'Value')
values{i} = app.(propName).Value;
end
% if isprop(property, 'Visible')
% visibilities{i} = app.(props{i}).Visible;
% end
end
file = uiputfile('*.mat', "Save Message" );
if file
save(file, 'props', 'values', 'visibilities');
end
end
function LoadButtonPushed(app, event) % Loading element
[file,path] = uigetfile('*.mat');
selectedfile = fullfile(file);
load(selectedfile)
end
【问题讨论】:
-
您调用
load然后退出该函数,您加载的所有变量都在LoadButtonPushed函数的工作区中,并且在该函数退出时对应用程序不可见 - 您希望这些变量发生什么?您是否添加了断点并逐步执行此函数以查看发生了什么?
标签: matlab matlab-app-designer