<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/253911</link>
    <title>MATLAB Central Newsreader - Writing text file with double and string on the same row</title>
    <description>Feed for thread: Writing text file with double and string on the same row</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>Wed, 17 Jun 2009 06:18:01 -0400</pubDate>
      <title>Writing text file with double and string on the same row</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/253911#658009</link>
      <author>Pete sherer</author>
      <description>Are there any way I can resolve this issue?&lt;br&gt;
&lt;br&gt;
a = [1 2 3]';&lt;br&gt;
b = {'a','gg','vb'}';&lt;br&gt;
c = [34 44 98]';&lt;br&gt;
fid = fopen( 'tmp.txt', 'wt');&lt;br&gt;
fprintf( fid,'%f %s %f\n', a, b, c);&lt;br&gt;
fclose( fid);&lt;br&gt;
&lt;br&gt;
??? Error using ==&amp;gt; fprintf&lt;br&gt;
Function is not defined for 'cell' inputs.&lt;br&gt;
&lt;br&gt;
Thank you very much.&lt;br&gt;
Pete</description>
    </item>
    <item>
      <pubDate>Wed, 17 Jun 2009 08:53:02 -0400</pubDate>
      <title>Re: Writing text file with double and string on the same row</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/253911#658038</link>
      <author>Jos </author>
      <description>&quot;Pete sherer&quot; &amp;lt;tsh@abg.com&amp;gt; wrote in message &amp;lt;h1a1qp$89c$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Are there any way I can resolve this issue?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a = [1 2 3]';&lt;br&gt;
&amp;gt; b = {'a','gg','vb'}';&lt;br&gt;
&amp;gt; c = [34 44 98]';&lt;br&gt;
&amp;gt; fid = fopen( 'tmp.txt', 'wt');&lt;br&gt;
&amp;gt; fprintf( fid,'%f %s %f\n', a, b, c);&lt;br&gt;
&amp;gt; fclose( fid);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ??? Error using ==&amp;gt; fprintf&lt;br&gt;
&amp;gt; Function is not defined for 'cell' inputs.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thank you very much.&lt;br&gt;
&amp;gt; Pete&lt;br&gt;
&lt;br&gt;
A solution would be to simply loop over the elements:&lt;br&gt;
&lt;br&gt;
for ii=1:3,&lt;br&gt;
&amp;nbsp;&amp;nbsp;fprintf( fid,'%f %s %f\n', a(ii), b{ii}, c(ii));&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
which is both readable and fast.&lt;br&gt;
&lt;br&gt;
hth&lt;br&gt;
Jos</description>
    </item>
    <item>
      <pubDate>Wed, 17 Jun 2009 15:21:01 -0400</pubDate>
      <title>Re: Writing text file with double and string on the same row</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/253911#658172</link>
      <author>Pete sherer</author>
      <description>I was trying to find a way to write it without using loop.&lt;br&gt;
Any hints?</description>
    </item>
    <item>
      <pubDate>Wed, 17 Jun 2009 15:36:02 -0400</pubDate>
      <title>Re: Writing text file with double and string on the same row</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/253911#658184</link>
      <author>us</author>
      <description>&quot;Pete sherer&quot; &amp;lt;tsh@abg.com&amp;gt; wrote in message &amp;lt;h1a1qp$89c$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Are there any way I can resolve this issue?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a = [1 2 3]';&lt;br&gt;
&amp;gt; b = {'a','gg','vb'}';&lt;br&gt;
&amp;gt; c = [34 44 98]';&lt;br&gt;
&amp;gt; fid = fopen( 'tmp.txt', 'wt');&lt;br&gt;
&amp;gt; fprintf( fid,'%f %s %f\n', a, b, c);&lt;br&gt;
&amp;gt; fclose( fid);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ??? Error using ==&amp;gt; fprintf&lt;br&gt;
&amp;gt; Function is not defined for 'cell' inputs.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thank you very much.&lt;br&gt;
&amp;gt; Pete&lt;br&gt;
&lt;br&gt;
you could take a look at this small FEX utility, which does what you want (and much more)...&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/23840&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/23840&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
us</description>
    </item>
    <item>
      <pubDate>Wed, 17 Jun 2009 18:44:02 -0400</pubDate>
      <title>Re: Writing text file with double and string on the same row</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/253911#658243</link>
      <author>Jos </author>
      <description>&quot;Pete sherer&quot; &amp;lt;tsh@abg.com&amp;gt; wrote in message &amp;lt;h1b1kt$od2$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I was trying to find a way to write it without using loop.&lt;br&gt;
&amp;gt; Any hints?&lt;br&gt;
&lt;br&gt;
Sure, if you insist ...&lt;br&gt;
&lt;br&gt;
A = [num2cell(a) b num2cell(c)].' ; % do not forget to transpose ...&lt;br&gt;
fprintf('%f %s %f\n',A{:})&lt;br&gt;
&lt;br&gt;
imho this is less readable and prone to errors&lt;br&gt;
&lt;br&gt;
Jos</description>
    </item>
  </channel>
</rss>

