MATLAB: Listdlg, giving memory to list dialog from previous execution.

listdlglistdlg memory

Hi,
I am using a list dialog in my code, allowing user to select the desired items. I want to introduce some kind of memory to the list dialog so that it remember the previously selected items.
Right now i am using following code for the list dialog. For example
r = {'Crunchy','Creamy','Natural','Chocolate'};
[Selection,ok] = listdlg('ListString',r);
for i = 1 : length(Selection)
some operation...
end
In above example if user has selected Crunchy and Creamy Then i want that next time "Crunchy" and "Creamy" should be pre-selected in the list dialog.
Thanks in advance for your suggestions, tips and hints.
Kind regards, \\ Arsalan

Best Answer

Will this do what you want?
r = {'Crunchy','Creamy','Natural','Chocolate'};
Selection=[];
for k=1:3
[Selection,ok] = listdlg('ListString',r,'InitialValue',Selection);
% Do more stuff
end