Hi,
I have a program but for some reason it doesn't work. I got a messagge: undefined function or variable.
Code:
function [C, Cdelta, P, Pdelta] = ch08(S,E,r,sigma,tau)
if tau > 0
d1 = (log(S/E)+(r+0.5*sigma^2)*(tau))/(sigma*sqrt(tau));
d2=d1-sigma*sqrt(tau);
N1=0.5*(1+erf(d1/sqrt(2)));
N2=0.5*(1+erf(d2/sqrt(2)));
C=S*N1-E*exp(-r*(tau))*N2;
Cdelta=N1;
P=C+E*exp(-r*(tau))-S;
Pdelta=Cdelta-1;
else
C=max(S-E,0);
Cdelta=0.5*(sign(S-E)+1);
P=max(E-S,0);
Pdelta=Cdelta-1;
end
Any ideas, why it doesn't work?
Thanks in advance!

댓글 수: 3

Jan
Jan 2017년 5월 27일
Please post the complete error message. Then we do not have to guess which variable or function is concerned and which line contains the problem.
How do you call this function? Do you start it using the Run button in the editor? Then you do not provide any input.
Abel Babu
Abel Babu 2017년 5월 30일
There is a good chance that the function has not been added in the MATLAB path. Either add the file in path or change the directory to the one that has the ch08.m file.
Natalia Timofeeva
Natalia Timofeeva 2017년 6월 3일
Now it works, thanks!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2017년 5월 27일

댓글:

2017년 6월 3일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by