Filter löschen
Filter löschen

Using fprintf to write multiple data into one file using a for loop

12 Ansichten (letzte 30 Tage)
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 Kommentar
Guillaume
Guillaume am 24 Jul. 2015
Bearbeitet: Guillaume am 24 Jul. 2015
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Muhammad Usman Saleem
Muhammad Usman Saleem am 24 Jul. 2015
this is possible , share some data

Community Treasure Hunt

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

Start Hunting!

Translated by