Saving and loading GUI data

3 vues (au cours des 30 derniers jours)
B_Richardson
B_Richardson le 11 Juil 2011
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 commentaires
Gerd
Gerd le 11 Juil 2011
Do you want the user to load and save a "working file" ?
B_Richardson
B_Richardson le 11 Juil 2011
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

Connectez-vous pour commenter.

Réponses (1)

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

Community Treasure Hunt

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

Start Hunting!

Translated by