<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239784</link>
    <title>MATLAB Central Newsreader - create a table using .txt file</title>
    <description>Feed for thread: create a table using .txt file</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>Sun, 23 Nov 2008 19:27:02 -0500</pubDate>
      <title>create a table using .txt file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239784#612738</link>
      <author>ashish </author>
      <description>I have loaded .txt file and stored it in a variable. How do i create a table using that data? I need to label each column and give it a title. &lt;br&gt;
Below is the .txt data&lt;br&gt;
1732 2 22&lt;br&gt;
1777 12 15&lt;br&gt;
1778 1 20&lt;br&gt;
1564 4 23&lt;br&gt;
1592 2 21&lt;br&gt;
1592 4 2&lt;br&gt;
2000 2 1&lt;br&gt;
2008 11 3&lt;br&gt;
2009 1 15&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thank you. </description>
    </item>
    <item>
      <pubDate>Sun, 23 Nov 2008 19:34:23 -0500</pubDate>
      <title>Re: create a table using .txt file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239784#612740</link>
      <author>Walter Roberson</author>
      <description>ashish wrote:&lt;br&gt;
&amp;gt; I have loaded .txt file and stored it in a variable. How do i create a table using that data? I need to label each column and give it a title. &lt;br&gt;
&amp;gt; Below is the .txt data&lt;br&gt;
&amp;gt; 1732 2 22&lt;br&gt;
&amp;gt; 1777 12 15&lt;br&gt;
&amp;gt; 1778 1 20&lt;br&gt;
&amp;gt; 1564 4 23&lt;br&gt;
&amp;gt; 1592 2 21&lt;br&gt;
&amp;gt; 1592 4 2&lt;br&gt;
&amp;gt; 2000 2 1&lt;br&gt;
&amp;gt; 2008 11 3&lt;br&gt;
&amp;gt; 2009 1 15&lt;br&gt;
&lt;br&gt;
Which version do you have? If you have R2008b, you can use the (newly official)&lt;br&gt;
uitable(); you can probably use num2cell() to get the proper cell array to feed in.&lt;br&gt;
(A usable uitable might also be in R2008a; before that I believe the uitable&lt;br&gt;
was undocumented and had notable problems.)&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
.signature note: I am now avoiding replying to unclear or ambiguous postings.&lt;br&gt;
Please review questions before posting them. Be specific. Use examples of what you mean,&lt;br&gt;
of what you don't mean. Specify boundary conditions, and data classes and value&lt;br&gt;
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?</description>
    </item>
    <item>
      <pubDate>Sun, 23 Nov 2008 20:04:02 -0500</pubDate>
      <title>Re: create a table using .txt file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239784#612743</link>
      <author>Andres </author>
      <description>&quot;ashish &quot; &amp;lt;ashishtx@hotmail.com&amp;gt; wrote in message &amp;lt;ggcaq6$h65$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I have loaded .txt file and stored it in a variable. How do i create a table using that data? I need to label each column and give it a title. &lt;br&gt;
&lt;br&gt;
By &quot;table&quot; you mean a new file? Then just use fprintf.&lt;br&gt;
&lt;br&gt;
d = [1732 2 22&lt;br&gt;
1777 12 15&lt;br&gt;
1778 1 20&lt;br&gt;
1564 4 23&lt;br&gt;
1592 2 21&lt;br&gt;
1592 4 2&lt;br&gt;
2000 2 1&lt;br&gt;
2008 11 3&lt;br&gt;
2009 1 15];&lt;br&gt;
&lt;br&gt;
titles = '&quot;Title1&quot;,&quot;Title2&quot;,&quot;Title3&quot;';&lt;br&gt;
&lt;br&gt;
% write to file with pc type line breaks ('\r\n'):&lt;br&gt;
fid = fopen('c:\mytable.csv','w');&lt;br&gt;
fprintf(fid, '%s\r\n', titles);&lt;br&gt;
fprintf(fid, '%f,%f,%f\r\n', d);&lt;br&gt;
fclose(fid)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Such a csv file should open correctly in standard spreadsheet software, like OpenOffice. If it is MS Excel, of course, you may look at xlswrite and use a single cell array.&lt;br&gt;
&lt;br&gt;
Regards&lt;br&gt;
Andres</description>
    </item>
  </channel>
</rss>

