Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: newbie girl that needs some help with loops and fprintf
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
tabby

Posts: 5
Registered: 8/30/13
newbie girl that needs some help with loops and fprintf
Posted: Sep 1, 2013 10:58 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

can somebody please please please help me

i am VERY VERY new to matlab, but i'm trying to learn it.

i've written a script that uses a couple of "for loops" to produce several "blocks" of data, like maybe a hundred blocks or more (only two blocks are shown below). when I run the script this is what goes across my command window, but that's not what ends up in my output file. only the last block of data ends up in it.

so here's an example of the output file


1 3.23 -422 21.1
1 3.25 -124 45.0
1 2.99 -378 33.3

2, 3.12, -601, 61.0
2, 3.22, -227, 41.7
2, 4.02, -327, 32.9

3 2.70 -129 61.8
3 1.91 -304 65.2
3 0.99 -198 63.6

.
.
.

175, 7.32, -201, 111.0
175, 6.25, -287, 101.7
175, 8.02, -327, 135.2


then I use this stuff below to print the data to a file

fid = fopen('output_file.dat', 'wt')

data_to_print = [block_number data_A data_B data_C]

fprintf(fid, '%d %0.6f %d %0.6f' data_to_print)

but like i said, all i get is the last block in my output file.

175, 7.32, -201, 111.0
175, 6.25, -287, 101.7
175, 8.02, -327, 135.2

can one of you guys please please help me learn how to write all the blocks of data to one file?

thanks so much Tabby




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.