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!