display(vol); step=zeros(1,period); for x = 1 : period nodes=nodes+x; step(1,x)=x; end value=zeros(period,period); interestrate = zeros(period,period); interestrate(1,1) = InterestRate; for n=2:period interestrate(n,1)=interestrate(n-1,1)*(1-vol(n-1)); end for n=2:period interestrate(n,n)=interestrate(n-1,n-1)*(vol(n-1)+1); end if period >= 3 for m=2:period-1 l=2; z=m; for n=z:period-1 interestrate(z+1,l)=interestrate(z,l-1)*(vol(z)+1); z=z+1; l=l+1; end end end display(interestrate); lastValue=zeros(1,period); if (type == 0) for x = 1: period if k < interestrate(period,period-x+1) lastValue(x)= N*(interestrate(period,period-x+1)-k)*t; else lastValue(x) = 0; end end else for x = 1: period if k > interestrate(period,period-x+1) lastValue(x)= N*(k-interestrate(period,period-x+1))*t; else lastValue(x) = 0; end end end display(lastValue); n = nodes; m = period; for x = 1 : period value(period,m)= lastValue(m)/(1+(interestrate(period,m)*t)); n=n-1; m=m-1; end p=period-1; for x = 1:(period-1) n=p; for j = 1:p
display(vol); step=zeros(1,period); for x = 1 : period nodes=nodes+x; step(1,x)=x; end value=zeros(period,period); interestrate = zeros(period,period); interestrate(1,1) = InterestRate; for n=2:period interestrate(n,1)=interestrate(n-1,1)*(1-vol(n-1)); end for n=2:period interestrate(n,n)=interestrate(n-1,n-1)*(vol(n-1)+1); end if period >= 3 for m=2:period-1 l=2; z=m; for n=z:period-1 interestrate(z+1,l)=interestrate(z,l-1)*(vol(z)+1); z=z+1; l=l+1; end end end display(interestrate); lastValue=zeros(1,period); if (type == 0) for x = 1: period if k < interestrate(period,period-x+1) lastValue(x)= N*(interestrate(period,period-x+1)-k)*t; else lastValue(x) = 0; end end else for x = 1: period if k > interestrate(period,period-x+1) lastValue(x)= N*(k-interestrate(period,period-x+1))*t; else lastValue(x) = 0; end end end display(lastValue); n = nodes; m = period; for x = 1 : period value(period,m)= lastValue(m)/(1+(interestrate(period,m)*t)); n=n-1; m=m-1; end p=period-1; for x = 1:(period-1) n=p; for j = 1:p
CapsFloors.docx