Why I can't get my output? What's wrong with line 13?
Show older comments

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 Comments
the cyclist
on 5 Oct 2015
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
on 5 Oct 2015
Edited: Shawn Miller
on 5 Oct 2015
Star Strider
on 6 Oct 2015
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
on 6 Oct 2015
Edited: Shawn Miller
on 6 Oct 2015
Joseph Cheng
on 6 Oct 2015
Edited: Joseph Cheng
on 6 Oct 2015
shawn read the cyclist's answer to remedy your comment above.
Accepted Answer
More Answers (0)
Categories
Find more on Financial Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!