Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
indexing data before and after sort
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello, I need to plot data from a significant number of text files that have the same last digit in their name. My attempt is in the following code. Indexing to the sorted numeric value of the text file name alone does not suffice to get the full path of the text file. Therefore, I need to also find the corresponding non-numeric value of the text file before sorting then join the two parts to get the content of the similarly named text files. I really appreciate the help.
A = { 'C:\MATLAB\folder1_txtfilename_Num_1.txt' ,
'C:\MATLAB\folder1_txtfilename_Num_2.txt' ,
'C:\MATLAB\folder1_txtfilename_Num_3.txt',
'C:\MATLAB\folder2_txtfilename_Num_1.txt',
'C:\MATLAB\folder2_txtfilename_Num_2.txt',
'C:\MATLAB\folder2_txtfilename_Num_3.txt'};
for ii = 1:numel(A)
h1{:,ii} = strsplit(A{:,ii}, 'Num') % seperate the text file name
txt1{:,ii} = h1{1, ii}{1, 1} % get the ~numeric value of the text file name
txt2{:,ii} = h1{1, ii}{1, 2} % get the numeric value of the text file name
[txt2_sorted,I2] = sort(txt2) % get sorted array and its index
end
% find all txt files with same number in txt2_sorted:
for ii = 1:numel(A)
I00 = txt2_sorted'
dd(ii) = cellfun ( @strcmp, I00(1), I00(ii) )
data1 = txt2_sorted(dd)
end
% find the
댓글 수: 3
Stephen23
2019년 5월 19일
@Housam: it seems that you are describing your attempted solution, rather than describing what you are actually trying to achieve.
Most likely there are simpler ways to achieve what you need: please clearly described what the aim is, together with example input and output data.
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!