title: how to store looping data in a single array or matrix?
body: <p>i have a program with nested loop. i want all the values after each loop is completed, to </p>
  
  <p>be stored in a single matrix A or array A.</p>
  
  <p>display should be like </p>
  
  <pre><code>A= value1
     value2
     value3
     etc...
  </code></pre>
  
  <p>where value1,value2,value3 are answers got at the end of each loop.</p>
  
  <p>here is the program</p>
  
  <pre><code>load('b2.txt');
  
  [M,N]=size(b2);
  
  amp=[1.75,2,2.25,2.5,2.75,3,3.25,3.5,3.75,4];
  
  
  %defining threshold 
  
  m=10501;
  
  for i=10575:75:21000
  
  
     a=b2(m:i,:);
  
     time=b2(i,2)
  
  t=40;
  
  sum1=0;
  
  sum2=0;
  
  sum3=0;
  
  sum4=0;
  
  sum5=0;
  
  sum6=0;
  
  sum7=0;
  
  sum8=0;
  
  sum9=0;
  
  sum10=0;
  
  
  for R=1:75
  
      if (a(R,3)&gt;=t) &amp;&amp; (a(R,3)&lt;t+5)
  
          sum1=sum1+a(R,1);
  
      elseif (a(R,3)&gt;=t+5) &amp;&amp; (a(R,3)&lt;t+10)
  
          sum2=sum2+a(R,1);
  
      elseif (a(R,3)&gt;=t+10) &amp;&amp; (a(R,3)&lt;t+15)
  
          sum3=sum3+a(R,1);
  
      elseif (a(R,3)&gt;=t+15) &amp;&amp; (a(R,3)&lt;t+20)
  
          sum4=sum4+a(R,1);
  
      elseif (a(R,3)&gt;=t+20) &amp;&amp; (a(R,3)&lt;t+25)
  
          sum5=sum5+a(R,1); 
  
      elseif (a(R,3)&gt;=t+25) &amp;&amp; (a(R,3)&lt;t+30)
  
          sum6=sum6+a(R,1);   
  
       elseif (a(R,3)&gt;=t+30) &amp;&amp; (a(R,3)&lt;t+35)
  
          sum7=sum7+a(R,1); 
  
       elseif (a(R,3)&gt;=t+35) &amp;&amp; (a(R,3)&lt;t+40)
  
  
          sum8=sum8+a(R,1);
  
       elseif (a(R,3)&gt;=t+40) &amp;&amp; (a(R,3)&lt;t+45)
  
          sum9=sum9+a(R,1); 
  
       elseif (a(R,3)&gt;=t+45) &amp;&amp; (a(R,3)&lt;t+50)
  
          sum10=sum10+a(R,1);   
  
      end
  
  cumulative_hits=[sum1,sum2,sum3,sum4,sum5,sum6,sum7,sum8,sum9,sum10];
  
  for count=1:10
  
              if cumulative_hits(1,count)&lt;= 0
  
              amplitude(1,count)= 0;  
  
          else
  
              amplitude(1,count)=amp(1,count);
  
              end
  
  end
  
  cumulative_hits(cumulative_hits==0)=[];
  
  amplitude(amplitude==0)=[];
  
  
          y=log10(cumulative_hits);
  
          p=polyfit(amplitude,y,1);
  
          f=polyval(p,amplitude);
  end
  
  %disp(p(1,1))
  
  abs(p(1))
  
  m=m+75;
  
  
  end
  </code></pre>
  
  <p>need this asap.. thanks :)</p>