How can i check if the new item which i want to add to list box if it is exist or not
i write this code but it is not working
[filename, pathname] = uigetfile( ... {'*.m', 'All matlab-Files (*.m)'; ... '*.*','All Files (*.*)'}, ... 'Select Matlab File');file = fullfile(pathname,filename);filename = filename(1:end-2);currentItems = get(handles.listbox1, 'String');if pathname == 0 returnelsefor n = 1:length(newItems) if filename == currentItems(n); uiwait(msgbox('The algorithm you select are exist! Please selesct another.','Error','modal')); [filename, pathname] = uigetfile( ... {'*.m', 'All matlab-Files (*.m)'; ... '*.*','All Files (*.*)'}, ... 'Select Matlab File');file = fullfile(pathname,filename);filename = filename(1:end-2); endendend currentItems{end+1} = filename;set(handles.listbox1,'String',currentItems);
Best Answer