MATLAB MATLAB symbolic function shouldn't be symbolic

  • Thread starter Thread starter GreenLRan
  • Start date Start date
  • Tags Tags
    Function Matlab
AI Thread Summary
The error encountered, "Undefined function or method 'gt' for input arguments of type 'sym'," arises from attempting to compare a symbolic variable with a numeric value in the condition `if check > 10`. The variable "check" is initially symbolic, leading to the error when evaluated. To resolve this issue, the code should convert the symbolic result of `limit(XF,x,0)` to a numeric value using `check = double(limit(XF,x,0))`. This change allows for proper numerical comparisons in the conditional statement, enabling the code to execute without errors.
GreenLRan
Messages
59
Reaction score
0
[SOLVED]

I am getting this error when I try to run the code (at bottom):

check =

1


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

Error in ==> homework at 15
if check > 10


The value "check" seems to be a real value, not symbolic. It outputs a value of 1 in the terminal. Can anyone help me resolve this problem?


CODE:



clear all
syms z p x;
z = -10;
p = 0;
while p <20
while z < 20
G1 = tf([1 z],[1 p]);
X1 = (x+z)/(x+p);
G2 = tf([1],[1 2.5 1]);
X2 = (1/(x^2+2.5*x+1));
TF = G1*G2/(1+G1*G2);
XF = X1*X2/(1+X1*X2);
z = z + .1;
check = limit(XF,x,0)
if check > 10
[Wn,Z] = damp(TF)
z
p

end
end
p = p+.1;
end
 
Last edited:
Physics news on Phys.org
Simply use check = double(limit(XF,x,0)).
 

Similar threads

Replies
3
Views
3K
Replies
2
Views
3K
Replies
4
Views
1K
Replies
4
Views
2K
Replies
1
Views
2K
Replies
4
Views
3K
Back
Top