title: Appending result in for loop matlab
body: <p>I have this loop (which is part of a much bigger code) which outputs the price (HW2FPrice) of a bond for successive <strong>SettleEvo</strong> dates.
   How do get it to output a single array of HW2FPrice rather than lots of individual outputs? I would like the array to be <strong>HW2FPrice Vs. SettleEvo</strong>. Many thanks,</p>
  
  <pre><code>for SettleEvo = Settle:datenum('14-Mar-2013');
  NumCouponsRemaining = cpncount(SettleEvo, Maturity, Period, Basis, 1, IssueDate); % Coupon payments remaining until maturity. Calculates the number of periods from start to finish.
  nPeriods = NumCouponsRemaining;
  
  
  
  [CFlowAmounts, CFlowDates] = cfamounts(CouponRate, SettleEvo, Maturity);
  CFlowTimes = yearfrac(SettleEvo,CFlowDates);
  CFlowZero = interp1(ZeroTimes,ZeroRates,CFlowTimes,'linear','extrap');
  CFlowDF_Zero = zero2disc(CFlowZero,CFlowDates,SettleEvo);
  Price_Zero = CFlowAmounts*CFlowDF_Zero';
  [CFlowAmounts, CFlowDates, TFactors, Factors] = cfamounts(CouponRate,SettleEvo,repmat(Maturity,1,nTrials),Period,Basis);
  CFlowDFSim = cumprod(exp(squeeze(-SimZeroRates(2:end,1,:).*stepSize)));
  </code></pre>
  
  <p>SimZeroRates is an array of (nPeriods,nTenors,nTrials);</p>
  
  <pre><code>Price_Ind = sum(CFlowAmounts(:,2:end).*CFlowDFSim',2);
  HW2FPrice = mean(Price_Ind)
  end
  </code></pre>