Saving and loading GUI data

3 ビュー (過去 30 日間)
B_Richardson
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],...
'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 Center および File ExchangeWhos についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by