%% Price Swaps By Specifying Multiple Term Structures Using RateSpec
% Price three swaps using two interest-rate curves. First, define the data for the interest-rate term structure:

StartDates = '01-May-2012'; 
EndDates = {'01-May-2013'; '01-May-2014';'01-May-2015';'01-May-2016'};
Rates = [[0.0356;0.041185;0.04489;0.047741],[0.0366;0.04218;0.04589;0.04974]];

%
% Create the RateSpec using intenvset.

RateSpec = intenvset('Rates', Rates, 'StartDates',StartDates,...
'EndDates', EndDates, 'Compounding', 1)

%
% Look at the Rates for the two interest-rate curves.

RateSpec.Rates

%
% Define the swap instruments.

Settle = '01-May-2012';
Maturity = '01-May-2015';
LegRate = [0.06 10]; 
Principal = [100;50;100];  % Three notional amounts

%
% Price three swaps using two curves.

Price = swapbyzero(RateSpec, LegRate, Settle, Maturity, 'Principal', Principal)

% Copyright 2015 The MathWorks, Inc.