Saving and loading GUI data

2 次查看(过去 30 天)
B_Richardson
B_Richardson 2011-7-11
Goodmorning everyone!
I have a question concerning the nature of data in a GUI. This code creates a figure with a popupmenu and a listbox. A cell array is created with 50 cells that need to be filled with the selections of the listbox and popupmenu:
function [] = pop_ex()
% Help goes here.
S.fh = figure('units','pixels',...
'position',[100 300 120 140],...
'menubar','none',...
'name','slider_ex',...
'numbertitle','off',...
'resize','off');
S.pp = uicontrol('style','pop',...
'unit','pix',...
'position',[20 20 80 40],...
'string',{'one','two','three','four'},...
'callback',@pp_call);
S.ls = uicontrol('style','list',...
'unit','pix',...
'position',[20 80 80 40],...
'min',0,'max',5,...
'string',{'lone','ltwo','lthree','lfour','lfive','lsix'});
S.C = cell(1,50);
S.cnt = 1;guidata(S.fh,S)
function [] = pp_call(varargin)
% Callback for the popup.
S = guidata(gcbf);
A = zeros(length(get(S.pp,'string')),length(get(S.ls,'string')));
A(get(S.pp,'val'),get(S.ls,'val')) = 1;
S.C(S.cnt) = {A}; % Update this particular element of the cell.
S.cnt = S.cnt + 1; % Increment the counter.
guidata(S.fh,S) % Resave the structure so updates are not lost.
S.C{:} % Show in the command window.
My question is instead of creating a new cell array on each run, how could I load the same cell array each time? So that the users could for instance, work on cells 1-15 one time. Then lets say 23-30 next time, and so on? (by the way, this is just test code and my final product will be built from GUIDE)
  2 个评论
Gerd
Gerd 2011-7-11
Do you want the user to load and save a "working file" ?
B_Richardson
B_Richardson 2011-7-11
What do you mean by a "working file?" I was thinking or writing the cell array to a csv file after each run then loading that same file whenever the GUI is ran? does that make sense? I'm not sure if that is the best approach

请先登录,再进行评论。

回答(1 个)

Veera Kanmani
Veera Kanmani 2018-4-20
https://in.mathworks.com/matlabcentral/answers/1591-how-do-i-save-and-restore-the-state-data-in-a-gui

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by