From: Keyur Patel on 13 Aug 2010 15:04 How would I make my code, so that the wav files from the current directory load onto the listbox for the gui?
From: Walter Roberson on 13 Aug 2010 15:15 Keyur Patel wrote: > How would I make my code, so that the wav files from the current > directory load onto the listbox for the gui? Use dir() to get the file information. Extract the name information from the structure array returned by dir(). Build either a character array or cell array of strings from those names, and use that character array or cell array as the value of the String property of the listbox .
From: ImageAnalyst on 13 Aug 2010 16:45 On Aug 13, 3:04 pm, "Keyur Patel" <patel_...(a)yahoo.com> wrote: > How would I make my code, so that the wav files from the current directory load onto the listbox for the gui? Here's some code. The adaptation to list only wav files is straightforward. Put a call to this function in your callback of your "Specify Folder..." button or menu item, or in your startup code.. IMPORTANT: you may need to join any lines split into two by the newsreader. %===================================================================== % --- Load up the listbox with image files in folder handles.handles.ImageFolder function handles=LoadImageList(handles) ListOfImageNames = {}; folder = handles.ImageFolder; if ~isempty(handles.ImageFolder) if exist(folder,'dir') == false msgboxw(['Folder ' folder ' does not exist.']); return; end else msgboxw('No folder specified as input for function LoadImageList.'); return; end % If it gets to here, the folder is good. ImageFiles = dir([handles.ImageFolder '/*.*']); for Index = 1:length(ImageFiles) baseFileName = ImageFiles(Index).name; [folder, name, extension, version] = fileparts(baseFileName); extension = upper(extension); switch lower(extension) case {'.png', '.bmp', '.jpg', '.tif', '.avi'} % Allow only PNG, TIF, JPG, or BMP images ListOfImageNames = [ListOfImageNames baseFileName]; otherwise end end set(handles.lstImageList,'string',ListOfImageNames); return
|
Pages: 1 Prev: deleting rows after a certain number Next: Reading files |