<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/155532</link>
    <title>MATLAB Central Newsreader - "for" loop &amp; string</title>
    <description>Feed for thread: "for" loop &amp; string</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The 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>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 03 Sep 2007 08:47:02 -0400</pubDate>
      <title>Re:</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/155532#390520</link>
      <author>Jos </author>
      <description>"Francesco " &amp;lt;fsarnari@maths.leeds.ac.uk&amp;gt; wrote in message&lt;br&gt;
&amp;lt;fbf96u$i98$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;lt;SNIP ... make a filename string from a number to use for load&lt;br&gt;
&lt;br&gt;
You can use the functional format of LOAD, which accepts a&lt;br&gt;
variable string as its input. You can create the contents of&lt;br&gt;
the variable string on the fly. For that you can use&lt;br&gt;
NUM2STR, STRCAT and [], but I found that SPRINTF is most&lt;br&gt;
flexible:&lt;br&gt;
&lt;br&gt;
i = 1 ;&lt;br&gt;
varstring = sprintf('file%03d.txt',i) &lt;br&gt;
load (varstring)&lt;br&gt;
&lt;br&gt;
hth&lt;br&gt;
Jos&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Mon, 03 Sep 2007 07:28:47 -0400</pubDate>
      <title>Re:</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/155532#390514</link>
      <author>Dan </author>
      <description>Hello&lt;br&gt;
&lt;br&gt;
try it this way (num2str and [] ... or have a look at strcat)&lt;br&gt;
&lt;br&gt;
filename_beginning='load filename_';&lt;br&gt;
filename_ending='.mat';&lt;br&gt;
for i=1:N&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;load([filename_beginning,num2str(i),filename_ending]);&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
Dan&lt;br&gt;
&lt;br&gt;
&amp;gt; Hi Everybody,&lt;br&gt;
&amp;gt; I have the following problem:&lt;br&gt;
&amp;gt; I would like to load a number N of files, say something &lt;br&gt;
&amp;gt; like&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; for i=1:N&lt;br&gt;
&amp;gt;    load filename_i.mat&lt;br&gt;
&amp;gt;    ...&lt;br&gt;
&amp;gt;    ...&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; where i is an integer (and positive) number.&lt;br&gt;
&amp;gt; Could you tell me how shall I introduce the index of &lt;br&gt;
&amp;gt; my loop into the filename?&lt;br&gt;
&amp;gt; Could you pls give me a simple example of that?&lt;br&gt;
&amp;gt; Many thanks,&lt;br&gt;
&amp;gt; Francesco&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Sun, 02 Sep 2007 21:16:14 -0400</pubDate>
      <title>"for" loop &amp; string</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/155532#390480</link>
      <author>Francesco </author>
      <description>Hi Everybody,&lt;br&gt;
I have the following problem:&lt;br&gt;
I would like to load a number N of files, say something &lt;br&gt;
like&lt;br&gt;
&lt;br&gt;
for i=1:N&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;load filename_i.mat&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
where i is an integer (and positive) number.&lt;br&gt;
Could you tell me how shall I introduce the index of &lt;br&gt;
my loop into the filename?&lt;br&gt;
Could you pls give me a simple example of that?&lt;br&gt;
Many thanks,&lt;br&gt;
Francesco&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
