Quad. The integrand function must return an output vector of the same length as the input vector

2 次查看(过去 30 天)
Hello, I've been trying to integrate a function using the quad function:
PS2=quad(@fintegrand,0,10)
fintegrand is a .m function.
However, I keep getting the error
Error using quad (line 79) The integrand function must return an output vector of the same length as the input vector.
What does this error mean?
I´ll copy part of the commands i entered to define the function. Thetas, alpha and sigma have been previously defined
function [integrand] = fintegrand(t) syms t NPDF1=(1/sqrt(2*pi))*exp((-0.5*(log(theta_star/theta_starb) + (alpha - .5*sigma) .* t ) ./ sigma ./ t.^0.5).^2)
NPDF2=(1/sqrt(2*pi))*exp((-0.5*(log(theta_star/theta_starb) - (alpha - .5*sigma) .* t ) ./ sigma ./ t.^0.5).^2)
NCDF1=0.5.*(1+erf((log(theta_starb*psia/Fpa) + (alpha - .5*sigma) .* (T-t)) ./ sigma ./ ((T-t).^0.5)./sqrt(2))) NCDF2=0.5.*(1+erf((log(theta_starb*psia/Fa) + (alpha - .5*sigma) .* (T-t)) ./ sigma ./ ((T-t).^0.5)./sqrt(2)))
integrand= (NPDF1.*((alpha - .5*sigma)-0.5.*t.^(-1).*(log(theta_star/theta_starb)+(alpha - .5*sigma).*t))./ sigma ./ sqrt(T) + exp (-2*(alpha - .5*sigma)/sigma^2*log(theta_star/theta_starb)).*NPDF2.*(-(alpha - .5*sigma)-0.5.*t.^(-1).*(log(theta_star/theta_starb)-(alpha - .5*sigma).*t))./ sigma ./ sqrt(T) ).*(NCDF1-NCDF2)
Can someone help me with this?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by