×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Exporting data from a vector in a loop

Exporting data from a vector in a loop

Exporting data from a vector in a loop

(OP)
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

RE: Exporting data from a vector in a loop

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

TTFN



RE: Exporting data from a vector in a loop

(OP)
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!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources