I'm now having problems getting this to work with a matrix. The string function only outputs the sum from the last item in the matrix.<br>e.g.<br><br>for i=1:5<br><div style="margin-left: 40px;">x=[1:5;6:10];<br></div>
<div style="margin-left: 40px;">execstr('x'+string(i)+'='+string(i*x))<br></div>end<br><br>x3=<br>30<br><br>but I need the full matrix outputted i.e.<br>x3=<br>3.     6.    9.   12.  15.<br>18.  21.  24.   27.  30.<br>
<br>Matt<br><br><div><span class="gmail_quote">On 01/03/2008, <b class="gmail_sendername">Matthew Albrecht</b> <<a href="mailto:mattyalbrecht@gmail.com">mattyalbrecht@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks, works well.<div><span class="e" id="q_1186845665112986_1"><br><br><div><span class="gmail_quote">On 29/02/2008, <b class="gmail_sendername">Eric Dubois</b> <<a href="mailto:grocer.toolbox@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">grocer.toolbox@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div>Do :</div>
<div> </div>
<div>for i=1:n</div>
<div>    execstr('x'+string(i)+'='+string(i))</div>
<div>end<br> </div>
<div>Or more efficiently (but less general) :</div>
<div> </div>
<div>execstr('x'+string([1:n])+'='+string([1:n])</div>
<div> </div>
<div>Eric.</div>
<div><br> </div>
<div><span class="gmail_quote">2008/2/29, Matthew Albrecht <<a href="mailto:mattyalbrecht@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">mattyalbrecht@gmail.com</a>>:</span><div><span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">I would like to keep track of the output of a for loop, so that each output is assigned sequentially to a new variable from 'x1' to 'xn'.<br>


In its most simplest form, I would like to be able to do this:<br><br>for i=1:n<br>x=i<br>end<br>
<div style="margin-left: 40px;">x1=1<br> </div>
<div style="margin-left: 40px;">x2=2<br> </div>
<div style="margin-left: 40px;">....<br> </div>
<div style="margin-left: 40px;">xn=n<br> </div><br>Where currently it outputs<br>
<div style="margin-left: 40px;">x=1<br> </div>
<div style="margin-left: 40px;">x=2<br> </div>
<div style="margin-left: 40px;">...<br> </div>
<div style="margin-left: 40px;">x=n<br><br> </div>Thanks<br>Matt<br></blockquote></span></div></div><br>
</blockquote></div><br>
</span></div></blockquote></div><br>