Integral function: scalar to integrate over turns into large vector
显示 更早的评论
I have encountered a problem with the Integral(fun,xmin,xmax) function.
syms phi
params = [0.1;0.2;0.05;0.3;0.2;0.1];
R = 2.1;
S = 150;
K = 151;
tau = 0.2;
V = 0.1;
test_f1 = integral(@(phi)SV_f1(phi, params, R, S, K, tau,V),0,inf)
turns my phi scalar into a 1x150 vector inside my function. Using debug mode I could see that before anything happens inside my function the phi scalar that has been called into the function is recognized as a 1x150 vector. I have absolutely no idea how to move forward right now, so any help would be very much appreciated. Thanks.
in case you are interested in my objective function here it is:
function f1_end = SV_f1(phi, params, R, S, K, tau,V)
kappa_V = params(1);
theta_V = params(2);
sigma_V = params(3);
kappa_R = params(4);
sigma_R = params(5);
rho = params(6);
B = exp(-R*tau);
eta_R = sqrt(kappa_R^2 - 2*sigma_R^2*j*phi);
eta_Rstar = sqrt(kappa_R^2 - 2*sigma_R^2*(j*phi-1));
eta_V = sqrt( (kappa_V - (1+j*phi)*rho*sigma_V)^2 - j*phi*(j*phi+1)*sigma_V^2 );
eta_Vstar = sqrt( (kappa_V - j*phi*rho*sigma_V)^2 - j*phi*(j*phi - 1)*sigma_V^2 );
f1 = exp(-j*phi*log(B) - (theta_V/sigma_V^2)*(2*log(1-((eta_V-kappa_V+(1+j*phi)*rho*sigma_V)*(1-exp(-eta_V*tau)))/(2*eta_V))) ...
-(theta_V/sigma_V^2)*(eta_V-kappa_V+(1+j*phi)*rho*sigma_V)*tau+j*phi*log(S) ...
+((j*phi*(j*phi+1)*(1-exp(-eta_V*tau)))/(2*eta_V-(eta_V-kappa_V+(1+j*phi)*rho*sigma_V)*(1-exp(-eta_V*tau))))*V);
f1_end = R * exp( (exp(-j*phi*log(K)) * f1) / (j*phi));
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!