Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting data from a vector in a loop

Status
Not open for further replies.

Nikke

Electrical
Nov 16, 2005
2
I have to export 2 vectors in 2 different .txt files. My entire program is a loop repeated about 250 times. At the end of every loop, I want to export the results (2 vectors, one is 1X8 and one is 1X4) in two different .txt files (ie: a.txt and b.txt). I've tried to use the function "dlmwrite" this way:

>>dlmwrite('a.txt', C, ';');
>>dlmwrite('b.txt, O, ';');

but the files are overwrited everytime the loop is repeated. So my solutions are twice but I really dunno how to do them:
1) Change the name of the .txt file for every loop I make, so that at the end of the program I have 250X2 files.
2) Create two tables where I write the values of C and O for every loop without overwriting the existing values, so that at the end of the program I have 2 files (two tables in this case) with 250 rows and 8 columns for the first file and 4 columns for the second file.

The second solution is the better for me and maybe is simplier too.

Nikke
 
Replies continue below

Recommended for you

Why do you not use dlmwrite with the -append switch?

TTFN



 
I'll try that thx.

Anyway I think I've solved by using a matrix for data storing instead of a vector, and by switching rows at every loop. Seems it works well.

Thanks for the tip!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor