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: fprintf to write array to text file
Replies: 10   Last Post: Apr 6, 2012 7:53 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Walter Roberson

Posts: 5,173
Registered: 2/26/06
Re: fprintf to write array to text file
Posted: Jan 11, 2008 1:16 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

In article <fm8b2i$hhn$1@fred.mathworks.com>,
Tim <timbrown@nospamhere.nope> wrote:
>zhangfujian wrote in message
>> A for loop may be is useful for your problem.
>> Try something like this. It works.
>>
>> savefile = 'temp.txt';
>> result1 = 5.3;
>> result2 = 3.3;
>> result3 = 1;
>> mainArray = [1.2 2.3 3.4 ; 11.3 1.4 5.6 ; 1.5 2.3 10.2]
>>
>>
>> %Sample Code:
>> fprintf(myfile, '%g\t%g\t%g\n',mainArray(i,:));


>(1) So there is really no other way to add a whole array to
>a text file?


cvswrite(), dlmwrite()

You can set the cell delimiter to be a tab or space.

dlmwrite offers a 'precision' option which can be the number
of significant digits or a format specifier string.
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers



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

[Privacy Policy] [Terms of Use]

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