Error using quad2d
3 views (last 30 days)
Show older comments
Hello everyone,
I am trying to run the function Bivariate_Meijer_G_Ask, with the command :
close all;clear
am1=[0]; bn1 =[1.2]; ap1 =[]; bq1 =[];
dn2 =[1 ,1]; cp2 =[]; cm2 =[1]; dq2 =[0];
fn3 =[]; ep3 =[0]; em3 =[1.2 ,2.3 ,3.4]; fq3 =[];
x =2; y =3;
Bivariate_Meijer_G_Ask(am1, ap1, bn1, bq1, cm2,cp2, dn2, dq2, em3, ep3, fn3, fq3, x, y)
However, I get the following error:
Error using quad2d (line 114)
C must be a finite, scalar, floating point constant or a function handle.
Error in Bivariate_Meijer_G_Ask (line 11)
out = (-1/(2.*pi)^2).*quad2d(F,cs-1j.*W,cs+1j.*W,
ct-1j.*W,ct+1j.*W,'Singular',true); %Increase MaxFunEvals for higher W
>Can someone please help me figure out this issue?
Thank you in advance!
function out = Bivariate_Meijer_G_Ask(am1, ap1, bn1, bq1, cm2,cp2, dn2, dq2, em3, ep3, fn3, fq3, x, y)
%***** Integrand definition *****
F = @(s,t) (GammaProd(am1,s+t) .* GammaProd(1-cm2,s).* GammaProd(dn2,-s) .* GammaProd(1-em3,t).* GammaProd(fn3,-t) .* (x.^s) .* (y.^t))./(GammaProd(1-ap1,-(s+t)) .* GammaProd(bq1, s+t) .* GammaProd(cp2,-s) .* GammaProd(1-dq2,s).* GammaProd(ep3,-t) .* GammaProd(1-fq3,t));
%***** Contour definition *****
Sups = min(dn2); Infs = -max(1-cm2); % cs
cs = (Sups + Infs)/2;% s between Sups and Infs
Supt = min(fn3); Inft = max([-am1-cs em3-1]);% t>-am1-s, s=cs
ct = Supt - ((Supt-Inft)/10);%t betweeen Supt and Inft
W = 10; % W
%***** Bivariate Meijer G *****
out = (-1/(2.*pi)^2).*quad2d(F,cs-1j.*W,cs+1j.*W, ct-1j.*W,ct+1j.*W,'Singular',true); %Increase MaxFunEvals for higher W
%***** GammaProd subfunction *****
function output = GammaProd(p,z)
[pp zz] = meshgrid(p,z);
if (isempty(p)) output = ones(size(z));
else output = reshape(prod(gamma(pp+zz),2),size(z));
end
end
end
0 Comments
Answers (1)
Walter Roberson
on 18 Feb 2022
Your fn3 is empty because you assign [] to it. Supt is min(fn3) but fn3 is empty so Supt is empty. ct is calculated based on Supt but Supt is empty so ct is empty. ct+1j.*W is empty because ct is empty. So the fourth parameter you pass to quad2d is empty.
am1=[0]; bn1 =[1.2]; ap1 =[]; bq1 =[];
dn2 =[1 ,1]; cp2 =[]; cm2 =[1]; dq2 =[0];
fn3 =[]; ep3 =[0]; em3 =[1.2 ,2.3 ,3.4]; fq3 =[];
x =2; y =3;
Bivariate_Meijer_G_Ask(am1, ap1, bn1, bq1, cm2,cp2, dn2, dq2, em3, ep3, fn3, fq3, x, y)
function out = Bivariate_Meijer_G_Ask(am1, ap1, bn1, bq1, cm2,cp2, dn2, dq2, em3, ep3, fn3, fq3, x, y)
%***** Integrand definition *****
F = @(s,t) (GammaProd(am1,s+t) .* GammaProd(1-cm2,s).* GammaProd(dn2,-s) .* GammaProd(1-em3,t).* GammaProd(fn3,-t) .* (x.^s) .* (y.^t))./(GammaProd(1-ap1,-(s+t)) .* GammaProd(bq1, s+t) .* GammaProd(cp2,-s) .* GammaProd(1-dq2,s).* GammaProd(ep3,-t) .* GammaProd(1-fq3,t));
%***** Contour definition *****
Sups = min(dn2); Infs = -max(1-cm2); % cs
cs = (Sups + Infs)/2;% s between Sups and Infs
Supt = min(fn3); Inft = max([-am1-cs em3-1]);% t>-am1-s, s=cs
ct = Supt - ((Supt-Inft)/10);%t betweeen Supt and Inft
W = 10; % W
%***** Bivariate Meijer G *****
whos
out = (-1/(2.*pi)^2).*quad2d(F,cs-1j.*W,cs+1j.*W, ct-1j.*W,ct+1j.*W,'Singular',true); %Increase MaxFunEvals for higher W
%***** GammaProd subfunction *****
function output = GammaProd(p,z)
[pp zz] = meshgrid(p,z);
if (isempty(p)) output = ones(size(z));
else output = reshape(prod(gamma(pp+zz),2),size(z));
end
end
end
4 Comments
Soumen Mondal
on 30 May 2022
@Walter Roberson Can you provide a example for which the code is running.
Walter Roberson
on 30 May 2022
F = @(x,y) sin(x) + cos(y) - atan2(y,x)
quad2d(F, -pi, 0, 0, pi)
See Also
Categories
Find more on Line Plots 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!