Several vectors as inputs to function
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi! I am trying to calculate values of Black-Scholes options using a function that requires inputs:
Values=BSCall(S,K,T,v,r)
Where v and r are both 1x11 arrays of risk-free rates and volatilities that correspont to each other. This means that I want in total 11 option values to be calculated. How can I do this without using loops?
Regards
Simon
댓글 수: 0
답변 (1개)
lvn
2014년 4월 17일
It all depends whether your function BSCall supports vector input. If it does, then just
Values=BSCall(S,K,T,v,r)
with v and r vectors should work. On the other if BSCall expects scalar v and r, then your only option will be to use a for loop (or of course to change BSCall to support vector input).
댓글 수: 2
lvn
2014년 4월 17일
What is the error message? In any case, I think there should be a dot before the second / in your formula.
참고 항목
카테고리
Help Center 및 File Exchange에서 Time Series Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!