Clear Filters
Clear Filters

Not enough input arguments. Error in iyp2. there are 4 varible@(tau,ztau,zpa,t) in the iyP(tau,ztau,zpa,t)but t is independent for sum

2 views (last 30 days)
timerperpeture()
Not enough input arguments.

Error in solution>@(tau,ztau,zpa,t)cell2mat(arrayfun(@(tau,ztau,zpa,t)iyP(tau,ztau,zpa,t),tau,ztau,zpa,t,'UniformOutput',0)) (line 32)
iyp2=@(tau,ztau,zpa,t)cell2mat(arrayfun(@(tau,ztau,zpa,t)iyP(tau,ztau,zpa,t),tau,ztau,zpa,t,'UniformOutput',0));

Error in solution>@(tau,ztau,zpa)((-1).^(t)).*real(iyp2(tau,ztau,zpa).*sqrt(2*alphaP).*(ztau.^(nu+1))./(sinh(zpa.*sqrt(alphaP/2)).*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alphaP).*coth(zpa.*sqrt(alphaP/2))))) (line 33)
H2=@(t)@(tau,ztau,zpa)((-1).^(t)).*real(iyp2(tau,ztau,zpa).*sqrt(2*alphaP).*(ztau.^(nu+1))./(sinh(zpa.*sqrt(alphaP/2)).*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alphaP).*coth(zpa.*sqrt(alphaP/2)))));

Error in solution>@(tau,ztau,zpa)la(tau,ztau,zpa)+sum(gH2(tau,ztau,zpa)) (line 35)
fgH2=@(tau,ztau,zpa)la(tau,ztau,zpa)+sum(gH2(tau,ztau,zpa));

Error in solution>@(tau,ztau,zpa)(fgH2(tau,ztau,zpa)+C(2:IP).*UMY(tau,ztau,zpa)) (line 44)
F=@(tau,ztau,zpa)(fgH2(tau,ztau,zpa)+C(2:IP).*UMY(tau,ztau,zpa));

Error in solution>@(tau,ztau,zpa)(exp(9/2)/B)*sum(F(tau,ztau,zpa))/8192*(s0*exp(vaps-r*tau)*normcdf(d1)-K*exp(-r*tau)*normcdf(d2)) (line 45)
AVGSU=@(tau,ztau,zpa)(exp(9/2)/B)*sum(F(tau,ztau,zpa))/8192*(s0*exp(vaps-r*tau)*normcdf(d1)-K*exp(-r*tau)*normcdf(d2));

Error in solution>@(tau,ztau,zpa)AVGSU(tau,ztau,zpa) (line 51)
Pfin=integral3(@(tau,ztau,zpa)AVGSU(tau,ztau,zpa),0,B,0,1,0,1,'AbsTol', 0,'RelTol',1) %inner expectation

Error in integral3>@(y,z)fun(x(1)*ones(size(z)),y,z) (line 129)
@(y,z)fun(x(1)*ones(size(z)),y,z), ...

Error in integral2Calc>integral2t/tensor (line 228)
Z = FUN(X,Y); NFE = NFE + 1;

Error in integral2Calc>integral2t (line 55)
[Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT);

Error in integral2Calc (line 9)
[q,errbnd] = integral2t(fun,xmin,xmax,ymin,ymax,optionstruct);

Error in integral3>innerintegral (line 128)
Q1 = integral2Calc( ...

Error in integral3>@(x)innerintegral(x,fun,yminx,ymaxx,zminxy,zmaxxy,integral2options) (line 111)
f = @(x)innerintegral(x, fun, yminx, ymaxx, ...

Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);

Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);

Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);

Error in integral3 (line 113)
Q = integralCalc(f,xmin,xmax,integralOptions);

Error in solution>timerperpeture (line 51)
Pfin=integral3(@(tau,ztau,zpa)AVGSU(tau,ztau,zpa),0,B,0,1,0,1,'AbsTol', 0,'RelTol',1) %inner expectation
function [Pfin]=timerperpeture(s0,v0,sigma,kappa,K,B) %varibles
s0=100;
v0=0.001;
K=90;
B=0.001;
r=0.01;
sigma=0.15;
kappa=0.1;
rho=0.5;
zpath=(2*sqrt(v0))/sigma;
deta=(4*kappa)/(sigma^2); % Bessel process parameter
nu=deta/2-1; % bessel model index
%syms tau ztau zpa
d=sqrt((1-rho^2)*B);
vaps=@(tau,ztau,zpa)-rho*(2*kappa/(sigma^2)-0.5).*(zpa)+(r*tau)-(B/2)+rho.*(ztau-zpath);
d1=@(tau,ztau,zpa)((log(s0/K)+vaps(tau,ztau,zpa)+(1-rho^2)*B))/d;
d2=@(tau,ztau,zpa)d1-d;
%% laplace inverse
alpha=(9)/(2*B); % laplace parameter,10
f1=@(tau,ztau,zpa,u)((2*sqrt(2*alpha*zpath.*ztau)./(sinh(tau.*sqrt(alpha./2))))./sqrt((pi^3).*zpa).*exp(-(2*sqrt(2*alpha*zpath.*ztau)./(sinh(tau.*sqrt(alpha./2)))).*cosh(u)-(pi^2)./(4.*zpa)-(u.^2)./(4.*zpa)).*sinh(u).*sin(pi.*u./(2.*zpa)));
iy1=@(tau,ztau,zpa)integral(@(u)f1(tau,ztau,zpa,u),0,200*pi,'ArrayValued',1);
iy2=@(tau,ztau,zpa)cell2mat(arrayfun(@(tau,ztau,zpa)iy1(tau,ztau,zpa),tau,ztau,zpa,'UniformOutput',0));
la=@(tau,ztau,zpa)0.5*real(iy2(tau,ztau,zpa).*sqrt(2*alpha).*(ztau.^(nu+1))./(sinh(tau.*sqrt(alpha./2)).*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alpha).*coth(zpa.*sqrt(alpha/2)))));
%la=0.5*real(iy2.*sqrt(2*alpha).*(ztau.^(nu+1))./(sh.*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alpha).*coth(zpa.*sqrt(alpha/2)))));
%% circle
NTR=5;
alphaP=@(t)complex(alpha,(t*pi)/B);
iyfP=@(tau,ztau,zpa,t,u)(2*sqrt(2*alphaP*zpath.*ztau)./sinh(zpa.*sqrt(alphaP/2)))./sqrt(pi^3.*tau).*exp(-(2*sqrt(2*alphaP*zpath.*ztau)./sinh(zpa.*sqrt(alphaP/2))).*cosh(u)-(pi^2-u.^2)./(4.*tau)).*sinh(u).*sin(pi.*u./2.*tau);
iyP=@(tau,ztau,zpa,t)integral(@(u)iyfP(tau,ztau,zpa,t,u),0,200*pi,'ArrayValued',1);
iyp2=@(tau,ztau,zpa,t)cell2mat(arrayfun(@(tau,ztau,zpa,t)iyP(tau,ztau,zpa,t),tau,ztau,zpa,t,'UniformOutput',0));
H2=@(t)@(tau,ztau,zpa)((-1).^(t)).*real(iyp2(tau,ztau,zpa).*sqrt(2*alphaP).*(ztau.^(nu+1))./(sinh(zpa.*sqrt(alphaP/2)).*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alphaP).*coth(zpa.*sqrt(alphaP/2)))));
gH2=H2(2:NTR);
fgH2=@(tau,ztau,zpa)la(tau,ztau,zpa)+sum(gH2(tau,ztau,zpa));
IP=14;
alpha2=@(N)complex(alpha,((NTR+N)*pi)/B);
sh2=@(N)sinh(zpa.*sqrt(alpha2/2));
gP2=@(N)2*sqrt(2*alpha2*zpath.*ztau)./sh2;
iyP2=@(N)@(tau,ztau,zpa)integral(@(u)gP2./sqrt(pi^3.*tau).*exp(-gP.*cosh(u)-(pi^2-u.^2)./(4.*tau)).*sinh(u).*sin(pi.*u./2.*tau),0,200*pi,'ArrayValued',1);
MY=@(N)@(tau,ztau,zpa)(-1)^(NTR+N).*real(iyP2.*sqrt(2*alpha2).*(ztau.^(nu+1))./(sh2.*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alpha2).*coth(zpa.*sqrt(alpha2/2)))));
UMY=MY(1:IP);
C=[1,14,91,364,1001,1848,3003,3432,3003,1848,1001,364,91,14,1];
F=@(tau,ztau,zpa)(fgH2(tau,ztau,zpa)+C(2:IP).*UMY(tau,ztau,zpa));
AVGSU=@(tau,ztau,zpa)(exp(9/2)/B)*sum(F(tau,ztau,zpa))/8192*(s0*exp(vaps-r*tau)*normcdf(d1)-K*exp(-r*tau)*normcdf(d2));
% dx=find(isnan(AVGSU)~=0);
% AVGSU(dx)=0;
% dy=find(isnan(AVGSU1)~=0);
% AVGSU1(dy)=0;
%disthree=@(tau,ztau,zpa,u)(U.*AVGSU)./8192;
Pfin=integral3(@(tau,ztau,zpa)AVGSU(tau,ztau,zpa),0,B,0,1,0,1,'AbsTol', 0,'RelTol',1) %inner expectation
end
  1 Comment
JICHAO ZHANG
JICHAO ZHANG on 20 Jun 2023
why 4 varibles together is wrong. whether if seperate varible. in fact , t is sum varible. rest of the varible are integral interval

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 20 Jun 2023
iyp2=@(tau,ztau,zpa,t)cell2mat(arrayfun(@(tau,ztau,zpa,t)iyP(tau,ztau,zpa,t),tau,ztau,zpa,t,'UniformOutput',0));
iyp2 is defined as expecting four input parameters: tau, ztau, zpa, t
H2=@(t)@(tau,ztau,zpa)((-1).^(t)).*real(iyp2(tau,ztau,zpa).*sqrt(2*alphaP).*(ztau.^(nu+1))./(sinh(zpa.*sqrt(alphaP/2)).*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alphaP).*coth(zpa.*sqrt(alphaP/2)))));
H2 calls iyp2 with only three input parameters: tau, ztau, zpa . It is missing the t value.
  1 Comment
JICHAO ZHANG
JICHAO ZHANG on 20 Jun 2023
I would like to do a cycle for t.
for example, t*exp(xyz),
then for t=1:5; there are vector
1*exp(xyz),2*exp(xyz),3*exp(xyz),4*exp(xyz),5*exp(xyz),
next step make sum, 1*exp(xyz)+2*exp(xyz)+3*exp(xyz)+4*exp(xyz)+5*exp(xyz),
finally, do integral by x,y,z varibles

Sign in to comment.

Categories

Find more on Special Functions in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!