??? Undefined function or method 'gammainc' for input arguments of type 'sym'.
Show older comments
[EDIT: 20110629 09:24 CDT - reformat - WDR]
I found a function here in mathworks called Erfi that i have to use it in a program. however, as I understood, this function doesn't work for s as symbolic . however, i need to do ilaplace for a function that uses it...
here is the error
-----------------------------
??? Undefined function or method 'gammainc' for input arguments of type
'sym'.
Error in ==> erfi1 at 19
ans=~isreal(t).*(-(sqrt(-t.^2)./(t+isreal(t))).*gammainc(-t.^2,1/2))+...
Error in ==> Epsf at 31
B5 =
D.^(7./4)*sqrt(pi)*dRH*(3*sqrt(D)-2*b*sqrt(s))*sqrt(-s./D)*(erfi1(sqrt(b)*(s./D).^(1./4))-erfi1(sqrt(r)*(s./D).^(1./4)))./(b.^(3./2)*s.^(9./4));
Error in ==> Egs at 25
y =
(1/k)*(a-b)*(a+b)*(Es/s)*D1*s*(b.^2*(nuc-1)-c.^2*(nuc+1))/(4*b.^2*(s*Epsf(s)-(s+lambda)*Epsf(s+lambda))+(b-c)*(b+c)*D1*((a.^2*(nus+1)-b.^2*(nus-1))));
Error in ==> Eg at 3
y = ilaplace(Egs(s),s,t);
Error in ==> graphe at 6
Ec = nu*Eg(t-tp);
-------------
and here is the code
---------------
k=1.7;
lambda=0.3;
tp=1;
nu = k*(1-exp(-lambda*tp));
t = 5:35;
Ec = nu*Eg(t-tp);
%graphe
plot(t,Ec)
------------------
function ans=erfi1(t)
% %erfi(x). The Imaginary error function, as it is defined in Mathematica
% %erfi(z)==erf(iz)/i (z could be complex) using
% %the incomplete gamma function in matlab: gammainc
% %Using "@": erfi = @(x) real(-sqrt(-1).*sign(x).*gammainc(-x.^2,1/2))
% %Note: limit(x->0) erfi(x)/x -> 2/sqrt(pi)
%
% %Example 1:
% x=linspace(0.001,6,100);
% y=exp(-x.^2).*erfi(x)./2./x;
% figure(1), clf;plot(x,y*sqrt(pi))
%
% %Example 2:
% [x,y]=meshgrid(linspace(-3,3,180),linspace(-3,3,180));
% z=x+i*y;
% figure(1), clf;contourf(x,y,log(erfi(z)))
% axis equal;axis off
xc=5.7;%cut for asymptotic approximation (when x is real)
it says that here is the error !
ans=~isreal(t).*(-(sqrt(-t.^2)./(t+isreal(t))).*gammainc(-t.^2,1/2))+...
isreal(t).*real(-sqrt(-1).*sign(t).*((t<xc).*gammainc(-t.^2,1/2))+...
(t>=xc).*exp(t.^2)./t/sqrt(pi));
------------------------
function y = Epsf(s)
%constantes
a = 14;
b=15;
c=25;
L=c-b;
r=c;
phi=15;
V=7*7*28;
ro=1000;
RHi=100;
RHb=50;
dRH = RHb-RHi;
nus=0.3;
D=1;
M=8.3*10.^(-6);
k=1.7;
Es=200000;
nuc=0.2;
lambda=0.3;
tp=1;
nu = k*(1-exp(-lambda*tp));
%-------------
%RH(c,s)
%Bi
B1 = b*sqrt(s)./sqrt(D);
B2 = c*sqrt(s)./sqrt(D);
B3 = r*sqrt(s)./sqrt(D);
B4 = -b*exp(B2)*(b-r)*(b+r)*RHi*sqrt(s)-3*c*exp(B2)*(b-r)*(b+r)*sqrt(s);
B5 = D.^(7./4)*sqrt(pi)*dRH*(3*sqrt(D)-2*b*sqrt(s))*sqrt(-s./D)*(erfi1(sqrt(b)*(s./D).^(1./4))-erfi1(sqrt(r)*(s./D).^(1./4)))./(b.^(3./2)*s.^(9./4));
RH= sqrt(D)*exp(-c*sqrt(s)./sqrt(D))*(-b*c*s./D).^(3./2)*((D).^(3./2)*sqrt(- b*c*s./D)*(-6*c.^(3./2)*(sqrt(6*D)*exp(B1)-exp(B3)*sqrt(D*r))*dRH- B4)./(b.^2*c.^2*s.^2)+B5)./(2*(3*c+b)*s.^(3./2));
y = -1.1*M*((c.^2-b.^2)*RHi./(2*s)-RH);
-----------------------------------------------
function y = Egs(s)
%constantes
a=14;
b=15;
c=25;
L=c-b;
r=c;
phi=15;
V=7*7*28;
ro=1000;
RHi=100;
RHb=50;
dRH = RHb-RHi;
nus=0.3;
D=1;
M=8.3*10.^(-6);
k=1.7;
Es=200000;
nuc=0.2;
lambda=0.3;
tp=1;
nu = k*(1-exp(-lambda*tp));
%------------------------
D1 = s*Epssa(s)-(s+lambda)*Epssa(s+lambda)/exp(lambda*tp);
y = (1/k)*(a-b)*(a+b)*(Es/s)*D1*s*(b.^2*(nuc-1)-c.^2*(nuc+1))/(4*b.^2*(s*Epsf(s)-(s+lambda)*Epsf(s+lambda))+(b-c)*(b+c)*D1*((a.^2*(nus+1)-b.^2*(nus-1))));
------------------------------------------------------
function y = Eg(t)
syms s;
y = ilaplace(Egs(s),s,t);
--------------------------------
function ans = Epssa(s)
syms t;
ans = laplace(Epsa(t),t,s);
-------------------------------
function y = Epsa(t)
y = -16.7*10.^(-6)*t.^(0.3);
--------------------------------
I really appreciate your help because I spent a lot of time in this issue :)
Answers (1)
Categories
Find more on Calculus 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!