Using fprintf to write multiple data into one file using a for loop
이전 댓글 표시
I have several folders each filled with 10-20 sets of data stored separately as csv files. The data is in the form of vectors in 2 columns [x y]. I have imported the data using Dir, I want to be able to process each piece of data one at a time using a for loop (as some of the processing involves a manual input), then save each vector of data in a single file in separate columns using fprintf. The vectors are all of different sizes, e.g. sample1 (1000x54), sample2 (755x2), sample3 (900x2) sample4 (1150x2)... and so on.
Any suggestions?
댓글 수: 1
I would rethink your format. text files are inherently a linear (row) format. The only way to write / read columns is by reading all the rows.
It would make more sense to me to write your vectors by row.
Otherwise, your only option is to prepare the content of the file in memory and write it to the file all at once. Reading a file with columns of different length is also going to be more complicated than a file with rows of different length.
답변 (1개)
Muhammad Usman Saleem
2015년 7월 24일
0 개 추천
this is possible , share some data
카테고리
도움말 센터 및 File Exchange에서 Variables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!