MATLAB symbolic function shouldn't be symbolic

  • Context: MATLAB 
  • Thread starter Thread starter GreenLRan
  • Start date Start date
  • Tags Tags
    Function Matlab
Click For Summary
SUMMARY

The forum discussion addresses an error encountered in MATLAB when attempting to compare a symbolic variable with a numeric threshold. The error message indicates that the function 'gt' is undefined for symbolic input types. The solution provided involves converting the symbolic result of the limit function to a double precision number using the command check = double(limit(XF,x,0)). This conversion allows for proper numerical comparison in the conditional statement.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of symbolic mathematics in MATLAB
  • Knowledge of transfer functions in control systems
  • Experience with MATLAB's limit function
NEXT STEPS
  • Explore MATLAB's symbolic toolbox for advanced symbolic computations
  • Learn about MATLAB's double function for type conversion
  • Research control system design using transfer functions in MATLAB
  • Investigate error handling and debugging techniques in MATLAB
USEFUL FOR

This discussion is beneficial for MATLAB users, particularly engineers and researchers working with symbolic mathematics and control systems who need to troubleshoot and optimize their code.

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 5 ·
Replies
5
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K