<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264845</link>
    <title>MATLAB Central Newsreader - Help please, how to write simple iterations and for loops</title>
    <description>Feed for thread: Help please, how to write simple iterations and for loops</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>Tue, 03 Nov 2009 15:00:20 -0500</pubDate>
      <title>Help please, how to write simple iterations and for loops</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264845#691735</link>
      <author>Dave Brown</author>
      <description>Im tryng to write an iteration using a &quot;for&quot; loop concerning this equation:&lt;br&gt;
&lt;br&gt;
PI = 0.5*((PI+1) + (PI-1) + ((deltaX * 3 * 0.2)/(0.00001))*(((PI+1) - (PI-1))/(2*deltaX)) + (((deltaX)^2 * 6 * 0.01 * 0.2 * 2)/0.00001^3))&lt;br&gt;
&lt;br&gt;
The equation is concerning pressure differences over change in length (deltaX) where PI is just the next pressure (e.g. P1, P2, P3...).  I need to find P1 over a range of values of deltaX:&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; deltaX = 0,0.005,0.01,0.015,0.02,0.025,0.03,0.035,0.04,0.045,0.05,0.055,0.06,0.065,0.07,0.075,0.08,0.085,0.00,0.095,0.1&lt;br&gt;
&lt;br&gt;
My first problem is that im not sure on how to get a rage of values for P1 from each different deltaX, although I am taking (PI+1)=0 and (PI-0)=0 for my first set of pressures (P1).  My second problem is I need to not only find P1 but rather keep on iterating the equation untill I get a convergance.  Now I think I know what to do to get values for P1 - put deltaX into a matrix and slove for a range of P1's - but how do i create an overall &quot;for&quot; loop which will keep on iterating this equation using (PI-1) and (PI+1)=0&lt;br&gt;
&lt;br&gt;
Any help in pointing me in the right direction would be fantastic and Im sorry if this is presented in an odd or confusing way, it's one of the first times I've ever used MATLAB or any other maths software so I'm still very much finding my feet.&lt;br&gt;
&lt;br&gt;
Thanks very much,&lt;br&gt;
&lt;br&gt;
Dave</description>
    </item>
    <item>
      <pubDate>Tue, 03 Nov 2009 18:15:04 -0500</pubDate>
      <title>Re: Help please, how to write simple iterations and for loops</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264845#691788</link>
      <author>ImageAnalyst</author>
      <description>Dave:&lt;br&gt;
What exactly is PI+1 or PI-1?  Is that the P value at the index after&lt;br&gt;
and before the current index (if so, you need to have the complete PI&lt;br&gt;
for all elements already calculated so that you can use them in the&lt;br&gt;
next pass)?  In other words, if you're calculating P(k) and it depends&lt;br&gt;
on P(k+1) but you haven't calculated P(k+1) already, then you're out&lt;br&gt;
of luck.&lt;br&gt;
&lt;br&gt;
Or is it literally the PI value plus or minus 1 (which is impossible&lt;br&gt;
because you haven't calculated PI yet)?</description>
    </item>
  </channel>
</rss>

