我有这个循环(它是更大代码的一部分),它输出连续SettleEvo日期的债券价格(HW2FPrice)。如何让它输出单个 HW2FPrice 数组而不是大量单独的输出?我希望数组是HW2FPrice Vs。解决Evo。非常感谢,
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)));
SimZeroRates 是 (nPeriods,nTenors,nTrials) 的数组;
Price_Ind = sum(CFlowAmounts(:,2:end).*CFlowDFSim',2);
HW2FPrice = mean(Price_Ind)
end