Extracting name of multiple files to use in Plotting multiple graph
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am creating a structure using the dir function , for all the text file present in a directory _text_files=dir(C:\Users\Desktop\.txt) (wild card star * is there before txt) _ ,now the structure text_files is having the names with the extension of all the text files inside the field 'name' of the sub-structures of text_files.
now i want the file names to be stored in a variable which i want to use as a label in plotting a graph for this i was trying to use the fileparts function , but the problem is that filespart function only accepts a file path as input argument thats what i know till now i can manually type the path and get the file name but i want to write a code that has to run iteratively , so i am avoiding this what i am doing is , i tried using the string concatenation function strcat to get the complete path as filepath=strcat('c:\Users\',text_files(1,1)) , and then using the fileparts function as [file_path file_name file_ext]=fileparts(filepath) , but it is not working , how can i do this.
Regards, Amit
0 commentaires
Réponses (1)
Jan
le 23 Juil 2013
text_files = dir('C:\Users\Desktop\*.txt');
text_names = {test_files.name};
n = numel(text_names);
name = cell(1, n);
for k = 1:n
[dummy, name{k}] = fileparts(text_names{k});
end
0 commentaires
Voir également
Catégories
En savoir plus sur Audio and Video Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!