Saving and loading GUI data

조회 수: 8(최근 30일)
B_Richardson 2011년 7월 11일
답변: Veera Kanmani 2018년 4월 20일
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)
  댓글 수: 2
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

댓글을 달려면 로그인하십시오.


Veera Kanmani
Veera Kanmani 2018년 4월 20일


Community Treasure Hunt

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

Start Hunting!

Translated by