Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

??? Undefined function or method 'gt' for input arguments of type 'sym'.

1,283 views
Skip to first unread message

sercan

unread,
Nov 8, 2008, 5:52:19 PM11/8/08
to
Hi. I am currently trying to run a code in MATLAB but I always encounter with the following error:

??? Undefined function or method 'gt' for input arguments of type 'sym'.

Error in ==> numeric at 52
end

the code is the following:

syms x1 x2 r L V y i It xl xu xr z y1 y2 h1 z1 z2 xold hl hu hr yl yu yr xrold yold ea es
r=1;
digits(2)
i=0;
L=10;
es=0.01;
ea=1.01;
V=12.4;
x1=0;
h1=r-x1;
y1=0.5*22/7*L*r^2-L*r^2*asin(h1/r)-h1*L*sqrt(r^2-h1^2)-(V);
z1=r-y1;
x2=1;
h2=r-x2;
y2=0.5*22/7*L*r^2-L*r^2*asin(h2/r)-h2*L*sqrt(r^2-h2^2)-(V);
z2=r-y2;
It=0;
xu=x1;
xl=x2;
while (ea >es)
if It==0
if z1<z2
xl=x1;
xu=x2;
end
end
if It>0
if yold>0
xu=xold;
end
if yold<0
xl=xold;
end
end
hl=r-xl;
yl=0.5*22/7*L*r^2-L*r^2*asin(hl/r)-hl*L*sqrt(r^2-hl^2)-(V);

hu=r-xu;
yu=0.5*22/7*L*r^2-L*r^2*asin(hu/r)-hu*L*sqrt(r^2-hu^2)-(V);

xr=xu-(yu*(xl-xu))/(yl-yu);

hr=r-xr;
yr=0.5*22/7*L*r^2-L*r^2*asin(hr/r)-hr*L*sqrt(r^2-hr^2)-(V);

if It>0
ea=abs((xr-xrold)/xr*100);
end
yold=yr;
xrold=xr;
It=It+1;
end

I have less time. I appreciate your replies, thanks

Walter Roberson

unread,
Nov 9, 2008, 8:05:44 PM11/9/08
to
sercan wrote:
> Hi. I am currently trying to run a code in MATLAB but I always encounter with the following error:
>
> ??? Undefined function or method 'gt' for input arguments of type 'sym'.
>
> Error in ==> numeric at 52
> end

> the code is the following:
>
> syms x1 x2 r L V y i It xl xu xr z y1 y2 h1 z1 z2 xold hl hu hr yl yu yr xrold yold ea es
> r=1;
> digits(2)
> i=0;

For future reference, note that if you assign a numeric value to a variable,
then its property of being symbolic is removed, so you did not need to declare
as many syms as you did.

> L=10;
> es=0.01;
> ea=1.01;
> V=12.4;
> x1=0;
> h1=r-x1;
> y1=0.5*22/7*L*r^2-L*r^2*asin(h1/r)-h1*L*sqrt(r^2-h1^2)-(V);
> z1=r-y1;
> x2=1;
> h2=r-x2;
> y2=0.5*22/7*L*r^2-L*r^2*asin(h2/r)-h2*L*sqrt(r^2-h2^2)-(V);
> z2=r-y2;
> It=0;
> xu=x1;
> xl=x2;
> while (ea >es)
> if It==0
> if z1<z2
> xl=x1;
> xu=x2;
> end
> end
> if It>0
> if yold>0

yold does not have a numeric value at this point, but you are trying to compare it
to 0. You cannot use the Matlab level to create a symbolic conditional result
"xu = xold if yold > 0 but otherwise xu is x2" for later evaluation.
If you want to create that kind of symbolic conditional result, you will
have to use the symbolic toolbox engine to create a piecewise() value.

> xu=xold;

xold does not have a numeric value at this point either.

> end
> if yold<0
> xl=xold;
> end
> end

I would suspect that you do not really want xold and yold to be symbolic constructs
in this code: I think you merely forgot to initialize them.

> hl=r-xl;
> yl=0.5*22/7*L*r^2-L*r^2*asin(hl/r)-hl*L*sqrt(r^2-hl^2)-(V);
>
> hu=r-xu;
> yu=0.5*22/7*L*r^2-L*r^2*asin(hu/r)-hu*L*sqrt(r^2-hu^2)-(V);
>
> xr=xu-(yu*(xl-xu))/(yl-yu);
>
> hr=r-xr;
> yr=0.5*22/7*L*r^2-L*r^2*asin(hr/r)-hr*L*sqrt(r^2-hr^2)-(V);
>
> if It>0
> ea=abs((xr-xrold)/xr*100);
> end
> yold=yr;
> xrold=xr;
> It=It+1;
> end

--
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?

0 new messages