numerically solving an equation involving a matlab function with multiple variables

3 ビュー (過去 30 日間)
Harry
Harry 2020 年 7 月 12 日
編集済み: Stephan 2020 年 7 月 12 日
I am interested in using a numerical equation solver to solve equations of the kind
known_1=my_function(unknown,known_2,known_3,...)
If there is a solution where unknown is between two bounds.
Thankfully I know that in the cases I am interested in there will either be 0 or 1 solutin within the bounds.
An example of an equation of this type that i am interested in is:
4==blsprice(5,2,0.05,unknown_time,0.2)
Where unkown_time is the variable i want to solve for
  2 件のコメント
Alan Stevens
Alan Stevens 2020 年 7 月 12 日
Look up help on function fzero.
Stephan
Stephan 2020 年 7 月 12 日
編集済み: Stephan 2020 年 7 月 12 日
fzero will not work, because it will try to use negative values, which leads to an error.
BTW: The time that results is about 13.693 years (for a call option):
>> blsprice(5,2,0.05,13.693,0.2)
ans =
4.0000
Are you sure you have the correct input values? The option already has an inner value of 3. To get one additional time value of 1 you would need this huge time. The option price for a half year for your example would be:
>> blsprice(5,2,0.05,0.5,0.2)
ans =
3.0494
Are you sure that you use correct inputs?

サインインしてコメントする。

採用された回答

Stephan
Stephan 2020 年 7 月 12 日
編集済み: Stephan 2020 年 7 月 12 日
fun = @(x) blsprice(5,2,0.05,x,0.2) - 4;
unknown_time = fsolve(fun,0.5)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by