<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237470</link>
    <title>MATLAB Central Newsreader - URGENT: Read text file and save matrices</title>
    <description>Feed for thread: URGENT: Read text file and save matrices</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>Mon, 13 Oct 2008 22:30:20 -0400</pubDate>
      <title>URGENT: Read text file and save matrices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237470#605055</link>
      <author>Diego Zegarra</author>
      <description>Hey guys I want to be able to read a bunch of files with the following type of structure but they all have different data dimensions.&lt;br&gt;
&lt;br&gt;
3&lt;br&gt;
10&lt;br&gt;
&lt;br&gt;
81 79 85 &lt;br&gt;
97 91 75 &lt;br&gt;
60 98 79 &lt;br&gt;
56 74 74 &lt;br&gt;
64 86 90&lt;br&gt;
59 98 74&lt;br&gt;
53 56 50&lt;br&gt;
90 76 68 &lt;br&gt;
53 57 60 &lt;br&gt;
73 72 62&lt;br&gt;
&lt;br&gt;
69 74 75 62 76 55 67 55 78 96&lt;br&gt;
69 79 69 97 53 59 72 76 54 56&lt;br&gt;
89 78 91 72 59 52 92 96 95 95&lt;br&gt;
74 98 99 68 55 69 66 76 52 92&lt;br&gt;
81 79 85 97 91 75 60 98 79 56 &lt;br&gt;
74 74 64 86 90 59 98 74 53 56 &lt;br&gt;
50 90 76 68 53 57 60 91 75 60 &lt;br&gt;
89 78 91 72 59 52 92 96 95 95&lt;br&gt;
74 98 99 68 55 69 66 76 52 92&lt;br&gt;
81 79 85 97 91 75 60 98 79 56&lt;br&gt;
&lt;br&gt;
74 49 64 86 90 59 98 74 53 56 &lt;br&gt;
50 90 76 68 53 57 60 91 75 60 &lt;br&gt;
89 78 91 72 59 52 92 96 95 95&lt;br&gt;
74 98 99 68 55 69 66 76 52 92&lt;br&gt;
81 79 85 97 91 75 60 98 79 56&lt;br&gt;
69 74 75 62 76 55 67 55 78 96&lt;br&gt;
69 79 69 97 53 59 72 76 54 56&lt;br&gt;
89 78 91 72 59 52 92 96 95 95&lt;br&gt;
74 98 99 68 55 69 66 76 52 92&lt;br&gt;
81 79 85 97 91 75 60 98 79 56 &lt;br&gt;
&lt;br&gt;
74 74 64 86 90 59 98 74 53 56 &lt;br&gt;
50 90 76 68 53 57 60 91 75 60 &lt;br&gt;
89 78 91 72 59 52 92 96 95 95&lt;br&gt;
81 79 85 97 91 75 60 98 79 56&lt;br&gt;
69 74 75 62 76 55 67 55 78 96&lt;br&gt;
69 79 69 97 53 59 72 76 54 56&lt;br&gt;
50 90 76 68 53 57 60 91 75 60 &lt;br&gt;
89 78 91 72 59 52 92 96 95 95&lt;br&gt;
74 98 99 68 55 69 66 76 52 92&lt;br&gt;
81 79 85 97 91 75 60 98 79 56&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
So let me explain what this means. First the 3 and 10 means 3 machines (m) and 10 jobs (n). I want to be able extract this and save it as a variable.&lt;br&gt;
&lt;br&gt;
Then the next block shows the processing times of n number of jobs at m number of machines. I also want to put this in a variable.&lt;br&gt;
&lt;br&gt;
After that there are m blocks of data (3 in this case) with a matrix of nxn representing setup times at each machine. I want to be able to save each of these blocks in a different variable each.&lt;br&gt;
&lt;br&gt;
Basically I want it to show this:&lt;br&gt;
&lt;br&gt;
A = [3 10]&lt;br&gt;
&lt;br&gt;
PT = [81 79 85 &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;97 91 75 &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;60 98 79 &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;56 74 74 &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;64 86 90&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;59 98 74&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;53 56 50&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;90 76 68 &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;53 57 60 &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;73 72 62]&lt;br&gt;
&lt;br&gt;
ST1 = [69 74 75 62 76 55 67 55 78 96&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;69 79 69 97 53 59 72 76 54 56&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;89 78 91 72 59 52 92 96 95 95&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;81 79 85 97 91 75 60 98 79 56]&lt;br&gt;
&lt;br&gt;
ST2 = [....]&lt;br&gt;
&lt;br&gt;
All my files will have a different number of machines and jobs so I want MATLAB to be able to read this automatically.&lt;br&gt;
&lt;br&gt;
ANY help is appreciated! Thank you so much and please try it! </description>
    </item>
    <item>
      <pubDate>Mon, 13 Oct 2008 23:13:02 -0400</pubDate>
      <title>Re: URGENT: Read text file and save matrices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237470#605063</link>
      <author>Diego Zegarra</author>
      <description>p.d. I am not asking you to code all this for me, an explanation or a guide would be really appreciated and if you have the code that would be even better. However, ANY help is good! Thank you</description>
    </item>
    <item>
      <pubDate>Mon, 13 Oct 2008 23:14:26 -0400</pubDate>
      <title>Re: URGENT: Read text file and save matrices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237470#605065</link>
      <author>dpb</author>
      <description>Diego Zegarra wrote:&lt;br&gt;
&amp;gt; p.d. I am not asking you to code all this for me, an explanation or a&lt;br&gt;
&amp;gt; guide would be really appreciated and if you have the code that would be&lt;br&gt;
&amp;gt; even better. However, ANY help is good! Thank you&lt;br&gt;
&lt;br&gt;
help iofun&lt;br&gt;
help textread&lt;br&gt;
&lt;br&gt;
--</description>
    </item>
    <item>
      <pubDate>Tue, 14 Oct 2008 03:09:01 -0400</pubDate>
      <title>Re: URGENT: Read text file and save matrices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237470#605076</link>
      <author>Walter Roberson</author>
      <description>dpb &amp;lt;none@non.net&amp;gt; wrote in message &amp;lt;gd0l0c$s3h$1@aioe.org&amp;gt;...&lt;br&gt;
&amp;gt; Diego Zegarra wrote:&lt;br&gt;
&amp;gt; &amp;gt; p.d. I am not asking you to code all this for me, an explanation or a&lt;br&gt;
&amp;gt; &amp;gt; guide would be really appreciated&lt;br&gt;
&lt;br&gt;
&amp;gt; help iofun&lt;br&gt;
&amp;gt; help textread&lt;br&gt;
&lt;br&gt;
I would think textscan() would be more appropriate for&lt;br&gt;
the problem than textread().&lt;br&gt;
&lt;br&gt;
After the first two lines are read, you know the number and sizes of the additional matrices. You can construct format strings for textscan() using&lt;br&gt;
FormatString = repmat('%f', 1, NumberPerLine);&lt;br&gt;
and then you can apply it as&lt;br&gt;
&lt;br&gt;
MatrixIn = textscan(fid, FormatString, NumberOfLines, ...&lt;br&gt;
'CollectOutput', true);</description>
    </item>
    <item>
      <pubDate>Tue, 14 Oct 2008 07:10:04 -0400</pubDate>
      <title>Re: URGENT: Read text file and save matrices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237470#605097</link>
      <author>Andres </author>
      <description>&quot;Diego Zegarra&quot; &amp;lt;diegozbb@gmail.com&amp;gt; wrote in message &amp;lt;gd0klu$3ea$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; p.d. I am not asking you to code all this for me, an explanation or a guide would be really appreciated and if you have the code that would be even better. However, ANY help is good! Thank you&lt;br&gt;
&lt;br&gt;
Oops, this is a doubleganger thread...&lt;br&gt;
But as is it urgent, I'll post my suggestion again:&lt;br&gt;
Use txt2mat from the file exchange to import all the numbers first&lt;br&gt;
&lt;br&gt;
A = txt2mat('fname.txt',0);&lt;br&gt;
&lt;br&gt;
and then extract all your variables from A by the help of A(1,1) and A(2,1).&lt;br&gt;
Regards&lt;br&gt;
Andres</description>
    </item>
    <item>
      <pubDate>Tue, 14 Oct 2008 15:42:01 -0400</pubDate>
      <title>Re: URGENT: Read text file and save matrices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237470#605201</link>
      <author>Diego Zegarra</author>
      <description>Hey Andres the function you are telling me (txt2mat) does not exist. What should I do?&lt;br&gt;
&lt;br&gt;
Any extra help? Could you show me how to get at least the first matrix after the first two lines?&lt;br&gt;
&lt;br&gt;
Thank you&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Andres &quot; &amp;lt;rantore@werb.deNoRs&amp;gt; wrote in message &amp;lt;gd1gkc$a1n$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Diego Zegarra&quot; &amp;lt;diegozbb@gmail.com&amp;gt; wrote in message &amp;lt;gd0klu$3ea$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; p.d. I am not asking you to code all this for me, an explanation or a guide would be really appreciated and if you have the code that would be even better. However, ANY help is good! Thank you&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Oops, this is a doubleganger thread...&lt;br&gt;
&amp;gt; But as is it urgent, I'll post my suggestion again:&lt;br&gt;
&amp;gt; Use txt2mat from the file exchange to import all the numbers first&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; A = txt2mat('fname.txt',0);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; and then extract all your variables from A by the help of A(1,1) and A(2,1).&lt;br&gt;
&amp;gt; Regards&lt;br&gt;
&amp;gt; Andres</description>
    </item>
    <item>
      <pubDate>Tue, 14 Oct 2008 19:16:02 -0400</pubDate>
      <title>Re: URGENT: Read text file and save matrices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237470#605234</link>
      <author>Barry Williams</author>
      <description>&quot;Diego Zegarra&quot; &amp;lt;diegozbb@gmail.com&amp;gt; wrote in message &amp;lt;gd2ek9$mfl$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hey Andres the function you are telling me (txt2mat) does not exist. What should I do?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Any extra help? Could you show me how to get at least the first matrix after the first two lines?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thank you&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &quot;Andres &quot; &amp;lt;rantore@werb.deNoRs&amp;gt; wrote in message &amp;lt;gd1gkc$a1n$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &quot;Diego Zegarra&quot; &amp;lt;diegozbb@gmail.com&amp;gt; wrote in message &amp;lt;gd0klu$3ea$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; p.d. I am not asking you to code all this for me, an explanation or a guide would be really appreciated and if you have the code that would be even better. However, ANY help is good! Thank you&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Oops, this is a doubleganger thread...&lt;br&gt;
&amp;gt; &amp;gt; But as is it urgent, I'll post my suggestion again:&lt;br&gt;
&amp;gt; &amp;gt; Use txt2mat from the file exchange to import all the numbers first&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; A = txt2mat('fname.txt',0);&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; and then extract all your variables from A by the help of A(1,1) and A(2,1).&lt;br&gt;
&amp;gt; &amp;gt; Regards&lt;br&gt;
&amp;gt; &amp;gt; Andres&lt;br&gt;
Diego,&lt;br&gt;
Because you indicated that you are looking for a quick response, I'll answer for Andres.  txt2mat is not a built-in MatLab function.  You need to get it from the file exchange library: &lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange&lt;/a&gt;&lt;br&gt;
Search for txt2mat&lt;br&gt;
Barry</description>
    </item>
    <item>
      <pubDate>Tue, 14 Oct 2008 20:44:02 -0400</pubDate>
      <title>Re: URGENT: Read text file and save matrices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237470#605253</link>
      <author>Diego Zegarra</author>
      <description>Thanks Barry I got it.&lt;br&gt;
&lt;br&gt;
&quot;Barry Williams&quot; &amp;lt;barry.r.williamsnospam@saic.com&amp;gt; wrote in message &amp;lt;gd2r5h$hd0$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Diego Zegarra&quot; &amp;lt;diegozbb@gmail.com&amp;gt; wrote in message &amp;lt;gd2ek9$mfl$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hey Andres the function you are telling me (txt2mat) does not exist. What should I do?&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Any extra help? Could you show me how to get at least the first matrix after the first two lines?&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thank you&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &quot;Andres &quot; &amp;lt;rantore@werb.deNoRs&amp;gt; wrote in message &amp;lt;gd1gkc$a1n$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &quot;Diego Zegarra&quot; &amp;lt;diegozbb@gmail.com&amp;gt; wrote in message &amp;lt;gd0klu$3ea$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; p.d. I am not asking you to code all this for me, an explanation or a guide would be really appreciated and if you have the code that would be even better. However, ANY help is good! Thank you&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Oops, this is a doubleganger thread...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; But as is it urgent, I'll post my suggestion again:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Use txt2mat from the file exchange to import all the numbers first&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; A = txt2mat('fname.txt',0);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; and then extract all your variables from A by the help of A(1,1) and A(2,1).&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Regards&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Andres&lt;br&gt;
&amp;gt; Diego,&lt;br&gt;
&amp;gt; Because you indicated that you are looking for a quick response, I'll answer for Andres.  txt2mat is not a built-in MatLab function.  You need to get it from the file exchange library: &lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange&lt;/a&gt;&lt;br&gt;
&amp;gt; Search for txt2mat&lt;br&gt;
&amp;gt; Barry</description>
    </item>
  </channel>
</rss>

