# Matlab Script for Black-Scholes Option Price

Matlab → Script → Input, Output → Black-Scholes Price

Write a script file where the program ask user to insert stock price, strike, interest rate, volatility, and time. And it should display the European style call and put option values in the style,

The value of call is ___, and the value of put is ___.

```%Call and put option values using BS model s=input('Insert initial stock price: '); k=input('Insert strike price: '); r=input('Insert annual interest rate: '); v=input('Insert volatility of the stck price: '); t=input('Insert time duration of the option: '); d1=(log(s/k)+(r+v^2/2)*t)/(v*sqrt(t)); d2=d1-v*sqrt(t); c=s*normcdf(d1)-k*exp(-r*t)*normcdf(d2); p=k*exp(-r*t)*normcdf(-d2)-s*normcdf(-d1); fprintf('The value of call is %g, and the value of put is %g.\n',c,p)```

Suppose we saved the program with the name “TestProgram”.

Command Window
```>> TestProgram Insert initial stock price: 50 Insert strike price: 50 Insert annual interest rate: 0.1 Insert volatility of the stck price: 0.4 Insert time duration of the option: 1 The value of call is 10.1592, and the value of put is 5.40111.``` Posted