Extracting name of multiple files to use in Plotting multiple graph
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Jan
2013년 7월 23일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio and Video Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!