writing a matrix of data contained in multiple file into a text file and saving as new text files
조회 수: 3 (최근 30일)
이전 댓글 표시
I have a folder containing 5000 text files having 48*3 data set as the content. I haev a text file where i ant to overwrite the content of these 5000 files individually to generate a new set of output files.
댓글 수: 0
답변 (1개)
Nilanshu Ranjan
2022년 11월 3일
I understand that you want to perform two tasks. First, you want to combine the data from 5000 text files into a single text file, perform some operations and then split the text file into new output files.
For both the tasks, you can use fprintf() function. Remember to open and close files using fopen() and fclose() . When using fopen() on a file that is not present in the path, MATLAB will create a new file.
A = [1 2; 3 4];
fid = fopen('file.txt','w');
fprintf(fid,'%d %d \n',A);
fclose(fid);
If you want to override textfiles you may use writematrix() function.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Low-Level File I/O에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!