MATLAB: How do i load a file automatically in a particular folder just by a part of the filename MATLAB I have a file named 'Annot_CU' in a folder.I want to load this file just finding the word 'Annot' in the particular folder. I am not able to find the code to this . Thank you in advance. Best Answer folder='C:\Path\To\Your\Data';list_of_files=dir(fullfile(folder,'Annot*'));%remove any matching folderslist_of_files([list_of_files.isdir])=[]; Related SolutionsMATLAB: Removing a folder from a directory outsaide the current directory of Matlab You just need to specify the full path of the folder you want to delete to rmdir. If you supply just the folder name, it assumes that folder is in the current directory. You can use fullfile to build the full path of the folder:parentfolder = 'C:\somewhere\on\the\drive';foldername = 'deleteme'rmdir(fullfile(parentfolder, foldername), 's'); MATLAB: Extract Variable from Filename You can use strtok() or other methods, but I prefer regexp here: filename = 'sitename.yr.synth.daily.mat' %example pieces = regexp(filename, '\.', 'split'); %divide by periods sitename = pieces{1}; Related QuestionFullfile to contain multiply file extensionApplication of “csvwrite(filename,M)” with different filenameI have file HMINT_3333.mat is located in any one director i need to load this file by directly getting filename can any body helpHow to iteratively increase number in filenameHow to assign results to varying filename
Best Answer