Numerically solving for the lower bound of integral

3 次查看(过去 30 天)
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 中查找有关 Function Creation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by