Clear Filters
Clear Filters

Saving and loading GUI data

5 views (last 30 days)
B_Richardson on 11 Jul 2011
Answered: Veera Kanmani on 20 Apr 2018
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],...
S.pp = uicontrol('style','pop',...
'position',[20 20 80 40],...
'callback',@pp_call); = uicontrol('style','list',...
'position',[20 80 80 40],...
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(,'string')));
A(get(S.pp,'val'),get(,'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)
Gerd on 11 Jul 2011
Do you want the user to load and save a "working file" ?
B_Richardson on 11 Jul 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

Sign in to comment.

Answers (1)

Veera Kanmani
Veera Kanmani on 20 Apr 2018

Community Treasure Hunt

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

Start Hunting!