Effacer les filtres
Effacer les filtres

Numerically solving for the lower bound of integral

2 vues (au cours des 30 derniers jours)
Nicolai Raith
Nicolai Raith le 11 Jan 2021
Commenté : Nicolai Raith le 11 Jan 2021
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.

Réponse acceptée

Walter Roberson
Walter Roberson le 11 Jan 2021
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)

Plus de réponses (0)

Catégories

En savoir plus sur Function Creation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by