From: Philip M on
Hey guys,

I'm new to Matlab and have a (little) question. I want to find the root of this function:

0.247=-sum(pvdef)*0.05+sum(pvprot)

pvdef and pvprot depend on rho.

r=0.02 ;
R=0.4 ;
A=0.001 ;
B=0.03 ;
x= -norminv(A/(1-R));
z= -norminv(B/(1-R));
k=1:20 ;
stetverzinsung=exp(-r*(k/4));
c=norminv(1-exp((-0.00625*k)/4));
sigma=[1 -(1-rho)^0.5; -(1-rho)^0.5 1];
for i=1:20,
p(i)=mvncdf([x,c(i)], 0, sigma);
q(i)=mvncdf([z,c(i)], 0, sigma);
E(i)=((1-R)/(B-A))*(p(i)-q(i));
EL(i+1)=E(i);
end
EL(1)=0;
for i=2:21,
pvprot(i-1)=stetverzinsung(i-1)*(EL(i)-EL(i-1));
pvdef(i-1)=0.25*stetverzinsung(i-1)*(1-EL(i));
end

I want to calculate the value of rho that makes my function zero. But actually I don't know how to do this because of the for loop.

Thanks for your help!

Philip