How to load multiple .dat files into MATLAB?
이전 댓글 표시
Hey,
I have 53 .dat (000n_3.dat, 000n_50.dat; 000n+1_3.dat, 000n+1_50.dat; etc. - as you can see, their names are similar but not purely consecutive) files all stored in the same directory, which I want to import into MATLAB all at the same time. Loading each of them works (e.g. load(0002_03.dat)) but what I want is to have all 53 of them loaded into a giant .mat spreadsheet from where I can neatly copy and paste all the rows and columns into an Excel spreadsheet.
How can I do this?
Thanks in advance.
댓글 수: 3
Jan
2016년 3월 3일
The question is not clear. How do you copy&paste values from a MAT file to an Excel sheet?
Bianca Elena Ivanof
2016년 3월 3일
편집: Bianca Elena Ivanof
2016년 3월 3일
Image Analyst
2016년 3월 3일
I think the script I gave in my answer below would be less tedious for the user.
채택된 답변
추가 답변 (2개)
SnukeN3
2019년 4월 26일
0 개 추천
I adapted this script to what I needed. It seems to be adding each file onto the bottom of the last. How do I get it to put new files into new columns?
댓글 수: 1
Image Analyst
2019년 4월 26일
Replace
allDataArray = [allDataArray; dataArray]; % Must have same number of columns
with this:
allDataArray = [allDataArray, dataArray]; % Must have same number of rows
SnukeN3
2019년 4월 27일
0 개 추천
Yep, that was it. Funny story, I tried the comma originally, but had mis-matched file lengths on the sample files I grabbed. Thanks for the help!
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!