From: Atahan Tolunay on
"Matt Fig" <spamanon(a)yahoo.com> wrote in message <hupeve$qv0$1(a)fred.mathworks.com>...
> str = 'Kelly.mat'
> str(1:end-4)
>
>
> Or, all at once:
>
> D = dir('*.mat');
> D = cellfun(@(x) x(1:end-4),{D.name},'Un',0);

This worked great. Now I tried to populate the list with this:

------------

D = dir('*.mat'); %gets all files ending with .mat
D = cellfun(@(x) x(1:end-4),{D.name},'Un',0); %removes .mat from file name

%List populated with users saved from previous sessions
m = 1;

while m < (length(D) + 1)
prev_str = get(handles.listbox1, 'String');
prev_str{end + 1} = D(m);
set(handles.listbox1, 'String', prev_str, 'Value', length(prev_str));
m = m + 1;
end

--------------


But this does not work because of the following reference field error:

??? Attempt to reference field of non-structure array.

Error in ==> MainGUI>listbox1_CreateFcn at 121
prev_str = get(handles.listbox1, 'String');

Error in ==> gui_mainfcn at 96
feval(varargin{:});

Error in ==> MainGUI at 42
gui_mainfcn(gui_State, varargin{:});

Error in ==> @(hObject,eventdata)MainGUI('listbox1_CreateFcn',hObject,eventdata,guidata(hObject))


??? Error using ==> struct2handle
Error while evaluating uicontrol CreateFcn

-----------
How can I solve this? Thanks.