I have dotted all the variable that are defined as a vector, but matlab gives me an error.
Do you see where is my problem?
function [C] = BlackScholesCall(S,K,t,r,sigma)% Calculates the price of a call option
% INPUT S 1x1 ... Current stock price (underlying)
% K 1x1 ... Strike price
% t 1x1 ... Time to maturity
% r 1x1 ... Risk-free interest rate
% sigma 1x1 ... standard deviation (volatility of the underlying)
% OUTPUT C 1x1 ... The price of a call option
% USAGE BlackScholesCall(S,K,t,r,sigma)
d1=(log(S/K.))+(r+(1/2)*sigma^2)*t)/(sigma*sqrt(t));d2=d1-sigma*sqrt(t.);C=(S*normcdf(d1))-(K.*(exp(-r*.t))*normcdf(d2));end
Code to call the function:
S = 22K = 20:25t = 0.1:0.1:0.6r = 0.02sigma = 0.25C = BlackScholesCall(S, K, t, r, sigma)
Thank you very much!
Best Answer