Hi,
the sequence of Output is not ok. How can I keep the data in sequnce. Kindly advise what I am missing ?
*.CSV files are like "D1.CSV, D2.CSV, D3.CSV............................D35.CSV"
The output file is not following this sequence.
files = dir('Data\*.CSV') ;
%files = natsortfiles({files.name}); %natsortfiles external Add In
N = length(files) ;
Output = cell(N,1) ;
for i = 1:N
Output{i} = readmatrix(files(i).name) ;
end
Advise please.

 채택된 답변

Stephen23
Stephen23 2024년 3월 12일
이동: Stephen23 2024년 3월 12일

1 개 추천

"How can I keep the data in sequnce."
Either use sufficient leading zeros in the filenames OR sort the filenames alphanumerically.
Kindly advise what I am missing ?"
files = dir('Data\*.CSV');
files = natsortfiles(files); % <- this

댓글 수: 2

Abdul Hannan
Abdul Hannan 2024년 3월 12일
이동: Stephen23 2024년 3월 12일
Yes, thankyou for correction. I was applying 'natsortfiles' unnecessarily using '.name'. Issue resolved thanks.
Stephen23
Stephen23 2024년 3월 12일
@Abdul Hannan: I hope that it helped. Please remember to click the accept button!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

제품

릴리스

R2023b

질문:

2024년 3월 12일

댓글:

2024년 3월 12일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by