Numerically solving for the lower bound of integral

조회 수: 2 (최근 30일)
Nicolai Raith
Nicolai Raith 2021년 1월 11일
댓글: Nicolai Raith 2021년 1월 11일
Hey everyone,
I'm very new with Matlab and struggling with finding the lower bound of an integral.
My idea was to use "vpasolve" and solve the integral nummerically for my lower bound given my function, upper bound and the result of the integral. However if I do so I get the error that "A and B must be floating-point scalars." and I do not have any clue how to tackle that issue.
I replaced in my original function F with x because I need to solve my integral over F (which is also my upper bound - here 79.335 but in my code a variable).
syms Lower_Bound x
Issue=Funct(V0,x,r,T,sigma_v);
fun=@(x)Issue/x;
[Lower_Bound]=vpasolve((integral(fun,Lower_Bound,79.335))==2);
The function "Issue" is given by:
function [Issue] = Funct(V,F,r,T,sigma_v)
d1=(log(V0/F)+(r+0.5*sigma_v^2)*T)/(sigma_v*sqrt(T));
d2=(log(V0/F)+(r-0.5*sigma_v^2)*T)/(sigma_v*sqrt(T))
Issue = normcdf(-d1)*V0+normcdf(d2)*F*exp((-r)*T);
I hope I stated my issue clear enough.
Many thanks in advance for your help.

채택된 답변

Walter Roberson
Walter Roberson 2021년 1월 11일
syms Lower_Bound x
Issue = Funct(V0,x,r,T,sigma_v);
fun = matlabFunction(Issue/x, 'vars', x);
LB_guess = 1.23;
LowerBound = fzero(@(LB) integral(fun, LB, 79.335) - 2, LB_guess)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by