<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/235740</link>
    <title>MATLAB Central Newsreader - dlmwrite</title>
    <description>Feed for thread: dlmwrite</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 09 Sep 2008 03:48:02 -0400</pubDate>
      <title>dlmwrite</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/235740#599399</link>
      <author>Jessica </author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
I'm trying to append words onto a preexisting .txt file. For example, my original a.txt file:&lt;br&gt;
&lt;br&gt;
Jo  9&lt;br&gt;
Tom 10&lt;br&gt;
Jon &lt;br&gt;
Tim 12&lt;br&gt;
&lt;br&gt;
And I want to append these values:&lt;br&gt;
&lt;br&gt;
ntxt={&lt;br&gt;
'Henry 34'&lt;br&gt;
'Bob 3'&lt;br&gt;
'Jim '&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
so that it produces:&lt;br&gt;
&lt;br&gt;
Jo  9&lt;br&gt;
Tom 10&lt;br&gt;
Jon &lt;br&gt;
Tim 12&lt;br&gt;
Henry 34&lt;br&gt;
Bob 3&lt;br&gt;
Jim &lt;br&gt;
&lt;br&gt;
I have tried the code:&lt;br&gt;
&lt;br&gt;
s=textread(a,'%s', 'delimiter','\n','whitespace','');&lt;br&gt;
Final=[s;ntxt];&lt;br&gt;
dlmwrite(fnam,char(Final), 'delimiter', '');&lt;br&gt;
&lt;br&gt;
However, this gives me very strange formating. I need the txt file to have things listed like:&lt;br&gt;
&lt;br&gt;
Jo  9&lt;br&gt;
Tom 10&lt;br&gt;
Jon &lt;br&gt;
Tim 12&lt;br&gt;
Henry 34&lt;br&gt;
Bob 3&lt;br&gt;
Jim &lt;br&gt;
&lt;br&gt;
Any suggestions?&lt;br&gt;
&lt;br&gt;
Thanks!</description>
    </item>
    <item>
      <pubDate>Tue, 09 Sep 2008 06:02:06 -0400</pubDate>
      <title>Re: dlmwrite</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/235740#599408</link>
      <author>Shanmugam Kannappan</author>
      <description>Hello Sir/Madam,&lt;br&gt;
&lt;br&gt;
You can do this operation by the folloing code.&lt;br&gt;
&lt;br&gt;
%% This part will do the first operation&lt;br&gt;
fp=fopen('a.txt','w+');&lt;br&gt;
fprintf(fp,'Jo 9\nTom 10\nJon\nTim 12\n')&lt;br&gt;
fclose(fp)&lt;br&gt;
%upto this u will have three rows only.&lt;br&gt;
%% U can append the data's to the existing file(a.txt)&lt;br&gt;
% by this code &lt;br&gt;
fp=fopen('a.txt','a+');&lt;br&gt;
fprintf(fp,'Henry 34\nBob 3\nJim\n')&lt;br&gt;
fclose(fp)&lt;br&gt;
% finaly u will get the txt file with all the strings in &lt;br&gt;
% Order&lt;br&gt;
open('a.txt')&lt;br&gt;
&lt;br&gt;
Regards&lt;br&gt;
Shanmugam.K&lt;br&gt;
&lt;br&gt;
&quot;Jessica &quot; &amp;lt;jyorzinski@ucdavis.edu&amp;gt; wrote in message &amp;lt;ga4rli$s9v$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'm trying to append words onto a preexisting .txt file. For example, my original a.txt file:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Jo  9&lt;br&gt;
&amp;gt; Tom 10&lt;br&gt;
&amp;gt; Jon &lt;br&gt;
&amp;gt; Tim 12&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; And I want to append these values:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ntxt={&lt;br&gt;
&amp;gt; 'Henry 34'&lt;br&gt;
&amp;gt; 'Bob 3'&lt;br&gt;
&amp;gt; 'Jim '&lt;br&gt;
&amp;gt; }&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; so that it produces:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Jo  9&lt;br&gt;
&amp;gt; Tom 10&lt;br&gt;
&amp;gt; Jon &lt;br&gt;
&amp;gt; Tim 12&lt;br&gt;
&amp;gt; Henry 34&lt;br&gt;
&amp;gt; Bob 3&lt;br&gt;
&amp;gt; Jim &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have tried the code:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; s=textread(a,'%s', 'delimiter','\n','whitespace','');&lt;br&gt;
&amp;gt; Final=[s;ntxt];&lt;br&gt;
&amp;gt; dlmwrite(fnam,char(Final), 'delimiter', '');&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; However, this gives me very strange formating. I need the txt file to have things listed like:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Jo  9&lt;br&gt;
&amp;gt; Tom 10&lt;br&gt;
&amp;gt; Jon &lt;br&gt;
&amp;gt; Tim 12&lt;br&gt;
&amp;gt; Henry 34&lt;br&gt;
&amp;gt; Bob 3&lt;br&gt;
&amp;gt; Jim &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Any suggestions?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks!</description>
    </item>
    <item>
      <pubDate>Tue, 09 Sep 2008 15:20:19 -0400</pubDate>
      <title>Re: dlmwrite</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/235740#599479</link>
      <author>Jessica </author>
      <description>Thanks for this advice. Unfortunately, the a.text file I gave was a shortened example for a very long file. Thus, I would not really want to type out everything that is contained in that file. Even if I do type out a shortened version of it, the formatting is still off.&lt;br&gt;
&lt;br&gt;
&quot;Shanmugam Kannappan&quot; &amp;lt;shanmugambe@gmail.com&amp;gt; wrote in message &amp;lt;ga53gu$sr7$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hello Sir/Madam,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; You can do this operation by the folloing code.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; %% This part will do the first operation&lt;br&gt;
&amp;gt; fp=fopen('a.txt','w+');&lt;br&gt;
&amp;gt; fprintf(fp,'Jo 9\nTom 10\nJon\nTim 12\n')&lt;br&gt;
&amp;gt; fclose(fp)&lt;br&gt;
&amp;gt; %upto this u will have three rows only.&lt;br&gt;
&amp;gt; %% U can append the data's to the existing file(a.txt)&lt;br&gt;
&amp;gt; % by this code &lt;br&gt;
&amp;gt; fp=fopen('a.txt','a+');&lt;br&gt;
&amp;gt; fprintf(fp,'Henry 34\nBob 3\nJim\n')&lt;br&gt;
&amp;gt; fclose(fp)&lt;br&gt;
&amp;gt; % finaly u will get the txt file with all the strings in &lt;br&gt;
&amp;gt; % Order&lt;br&gt;
&amp;gt; open('a.txt')&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Regards&lt;br&gt;
&amp;gt; Shanmugam.K&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &quot;Jessica &quot; &amp;lt;jyorzinski@ucdavis.edu&amp;gt; wrote in message &amp;lt;ga4rli$s9v$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I'm trying to append words onto a preexisting .txt file. For example, my original a.txt file:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Jo  9&lt;br&gt;
&amp;gt; &amp;gt; Tom 10&lt;br&gt;
&amp;gt; &amp;gt; Jon &lt;br&gt;
&amp;gt; &amp;gt; Tim 12&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; And I want to append these values:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; ntxt={&lt;br&gt;
&amp;gt; &amp;gt; 'Henry 34'&lt;br&gt;
&amp;gt; &amp;gt; 'Bob 3'&lt;br&gt;
&amp;gt; &amp;gt; 'Jim '&lt;br&gt;
&amp;gt; &amp;gt; }&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; so that it produces:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Jo  9&lt;br&gt;
&amp;gt; &amp;gt; Tom 10&lt;br&gt;
&amp;gt; &amp;gt; Jon &lt;br&gt;
&amp;gt; &amp;gt; Tim 12&lt;br&gt;
&amp;gt; &amp;gt; Henry 34&lt;br&gt;
&amp;gt; &amp;gt; Bob 3&lt;br&gt;
&amp;gt; &amp;gt; Jim &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I have tried the code:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; s=textread(a,'%s', 'delimiter','\n','whitespace','');&lt;br&gt;
&amp;gt; &amp;gt; Final=[s;ntxt];&lt;br&gt;
&amp;gt; &amp;gt; dlmwrite(fnam,char(Final), 'delimiter', '');&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; However, this gives me very strange formating. I need the txt file to have things listed like:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Jo  9&lt;br&gt;
&amp;gt; &amp;gt; Tom 10&lt;br&gt;
&amp;gt; &amp;gt; Jon &lt;br&gt;
&amp;gt; &amp;gt; Tim 12&lt;br&gt;
&amp;gt; &amp;gt; Henry 34&lt;br&gt;
&amp;gt; &amp;gt; Bob 3&lt;br&gt;
&amp;gt; &amp;gt; Jim &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Any suggestions?&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thanks!&lt;br&gt;
&amp;gt; </description>
    </item>
    <item>
      <pubDate>Tue, 09 Sep 2008 15:42:01 -0400</pubDate>
      <title>Re: dlmwrite</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/235740#599482</link>
      <author>Gavrilo Bozovic</author>
      <description>Hi!&lt;br&gt;
&lt;br&gt;
I just tried your matrix concatenation using simply [A;B], and it seemed to work...&lt;br&gt;
&lt;br&gt;
could you provide an example of the &quot;strange&quot; formatting it gives you?&lt;br&gt;
&lt;br&gt;
&quot;Jessica &quot; &amp;lt;jyorzinski@ucdavis.edu&amp;gt; wrote in message &amp;lt;ga4rli$s9v$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'm trying to append words onto a preexisting .txt file. For example, my original a.txt file:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Jo  9&lt;br&gt;
&amp;gt; Tom 10&lt;br&gt;
&amp;gt; Jon &lt;br&gt;
&amp;gt; Tim 12&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; And I want to append these values:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ntxt={&lt;br&gt;
&amp;gt; 'Henry 34'&lt;br&gt;
&amp;gt; 'Bob 3'&lt;br&gt;
&amp;gt; 'Jim '&lt;br&gt;
&amp;gt; }&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; so that it produces:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Jo  9&lt;br&gt;
&amp;gt; Tom 10&lt;br&gt;
&amp;gt; Jon &lt;br&gt;
&amp;gt; Tim 12&lt;br&gt;
&amp;gt; Henry 34&lt;br&gt;
&amp;gt; Bob 3&lt;br&gt;
&amp;gt; Jim &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have tried the code:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; s=textread(a,'%s', 'delimiter','\n','whitespace','');&lt;br&gt;
&amp;gt; Final=[s;ntxt];&lt;br&gt;
&amp;gt; dlmwrite(fnam,char(Final), 'delimiter', '');&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; However, this gives me very strange formating. I need the txt file to have things listed like:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Jo  9&lt;br&gt;
&amp;gt; Tom 10&lt;br&gt;
&amp;gt; Jon &lt;br&gt;
&amp;gt; Tim 12&lt;br&gt;
&amp;gt; Henry 34&lt;br&gt;
&amp;gt; Bob 3&lt;br&gt;
&amp;gt; Jim &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Any suggestions?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks!</description>
    </item>
    <item>
      <pubDate>Tue, 09 Sep 2008 16:00:22 -0400</pubDate>
      <title>Re: dlmwrite</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/235740#599485</link>
      <author>Gavrilo Bozovic</author>
      <description>BTW, if you want to read the file a.txt, 'textread(a,...)' cannot work like this.&lt;br&gt;
&lt;br&gt;
you either have to define:&lt;br&gt;
&lt;br&gt;
a = 'a.txt'&lt;br&gt;
&lt;br&gt;
or write&lt;br&gt;
&lt;br&gt;
textread('a.txt',...)&lt;br&gt;
&lt;br&gt;
I guess you did either one of these two, otherwise you would have had an execution error.</description>
    </item>
  </channel>
</rss>

