Why I can't get my output? What's wrong with line 13?
이전 댓글 표시

function [call,put,calldif,putdif]=bs(S,r,T,sigma,K,q)
% S is current stock price
% r is annualized risk free rate
% T is time to expiration (in years)
% sigma is annualized stock return standard deviation/volatility
% K is strike price
% q is annualized dividend rate
temp1=(log(S/K)+(r-q+sigma^2/2)*T)/(sigma*T^0.5);
temp2=temp1-sigma*T^0.5;
call=S*exp(-q*T)*normcdf(temp1)-K*exp(-r*T)*normcdf(temp2);
put=-S*exp(-q*T)*normcdf(-temp1)+K*exp(-r*T)*normcdf(-temp2);
[a,b]=blsprice(S,K,r,T,sigma,q);
[calldif,putdif]=[call,put]-[a,b]
end
댓글 수: 5
the cyclist
2015년 10월 5일
For future reference, it's better to post code, rather than an image of code, so that we can paste it into a file to test.
Shawn Miller
2015년 10월 5일
편집: Shawn Miller
2015년 10월 5일
Star Strider
2015년 10월 6일
Is your code throwing an error? If so, please copy and paste the entire red text from your Command Window and paste it to a Comment here.
What are the sizes of ‘call’, ‘put’, ‘a’ and ‘b’?
Shawn Miller
2015년 10월 6일
편집: Shawn Miller
2015년 10월 6일
Joseph Cheng
2015년 10월 6일
편집: Joseph Cheng
2015년 10월 6일
shawn read the cyclist's answer to remedy your comment above.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Financial Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!