<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265261</link>
    <title>MATLAB Central Newsreader - how to name a vector with a variable name to store previous results</title>
    <description>Feed for thread: how to name a vector with a variable name to store previous results</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>Sat, 07 Nov 2009 22:33:01 -0500</pubDate>
      <title>how to name a vector with a variable name to store previous results</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265261#692934</link>
      <author>Jose </author>
      <description>Hello,&lt;br&gt;
I have been tryiing to defene a vector which has to have a diferent name acording to some variables, in order to keep the results from previous results,&lt;br&gt;
&lt;br&gt;
let say for example, I am studying the effect of 3 variables in a process, then:&lt;br&gt;
from previous calculations I have  all the results for each case, made by loops,, now I need to store all this reults in a vecto wich the name is denined by the correpondent case:&lt;br&gt;
&lt;br&gt;
let say, the variables are &quot;i&quot;, &quot;j&quot; and &quot;k&quot;, &lt;br&gt;
then for example when i=2, j=5 and k=7, the result from previous calculations is&lt;br&gt;
&lt;br&gt;
result = [23 34  45 56 78]&lt;br&gt;
&lt;br&gt;
I can create the name like this:&lt;br&gt;
for i = 1:imax                  &lt;br&gt;
&amp;nbsp;&amp;nbsp;for j=1:jmax &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for k = 1:kmax&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;name = sprintf (result_j%d_j%d_k%d',[i j k])&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;end &lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
.. Now, how can I define that &quot;name&quot; is equal to the vector &quot;result&quot; ???&lt;br&gt;
&amp;nbsp;&amp;nbsp;&lt;br&gt;
to finally get, for example:&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result_i2_j5_k7 = [23 34  45 56 78]&lt;br&gt;
&lt;br&gt;
Thank you very much for you help,&lt;br&gt;
Regards.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</description>
    </item>
    <item>
      <pubDate>Sat, 07 Nov 2009 23:21:04 -0500</pubDate>
      <title>Re: how to name a vector with a variable name to store previous</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265261#692937</link>
      <author>Chan Huntington</author>
      <description>Hi Jose,&lt;br&gt;
&lt;br&gt;
If i understand your question correctly, you should be able to use 'eval', which concatenates a string and evaluates it as an expression.  From your description:&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; eval(['result_i', num2str(i),'_j',num2str(j),'_k',num2str(k),' = [23 34 45 56 78]'])&lt;br&gt;
&lt;br&gt;
You might also find the function genvarname to be useful.  Best,&lt;br&gt;
Chan</description>
    </item>
    <item>
      <pubDate>Sun, 08 Nov 2009 01:35:05 -0500</pubDate>
      <title>Re: how to name a vector with a variable name to store previous</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265261#692944</link>
      <author>Jose </author>
      <description>Hi Chan,&lt;br&gt;
&lt;br&gt;
Thank you very much for your reply, it works perfectly!!&lt;br&gt;
Than you so much!!&lt;br&gt;
&lt;br&gt;
kind regards.</description>
    </item>
    <item>
      <pubDate>Sun, 08 Nov 2009 23:21:20 -0500</pubDate>
      <title>Re: how to name a vector with a variable name to store previous results</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265261#693093</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Jose &quot; &amp;lt;mylordjose@hotmail.com&amp;gt; wrote in message &lt;br&gt;
news:hd4sit$f6r$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Hello,&lt;br&gt;
&amp;gt; I have been tryiing to defene a vector which has to have a diferent name &lt;br&gt;
&amp;gt; acording to some variables, in order to keep the results from previous &lt;br&gt;
&amp;gt; results,&lt;br&gt;
&lt;br&gt;
DO NOT DO THIS.&lt;br&gt;
&lt;br&gt;
See Q4.6 in the newsgroup FAQ for some of the reasons why you shouldn't and &lt;br&gt;
some of the alternatives.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com&lt;br&gt;
comp.soft-sys.matlab (CSSM) FAQ: &lt;a href=&quot;http://matlabwiki.mathworks.com/MATLAB_FAQ&quot;&gt;http://matlabwiki.mathworks.com/MATLAB_FAQ&lt;/a&gt; </description>
    </item>
  </channel>
</rss>

