symbolic variable
2 views (last 30 days)
Show older comments
'G' is a function of symbolic variable of 'b' the solve for b gives d=solve(G) a symbolic n*1 matrix but I'm not able to find the min or max even >(greater than sign)of this matrix. Matlab shows this following error Undefined function or method 'gt' for input arguments of type 'sym'.
0 Comments
Accepted Answer
Walter Roberson
on 8 Mar 2011
re=solve(GG); will return symbolic numbers. You need to apply double() to the symbolic numbers to convert them to floating point numbers.
0 Comments
More Answers (1)
Mike
on 8 Mar 2011
Since you haven't given explicit code one, can only speculate on the contents of your matrix d. However, here is an explicit example that I believe illustrates the issue. Say you have
>> syms a b c x;
>> results=solve('a*x^2 + b*x + c')
This gives
results =
-(b + (b^2 - 4*a*c)^(1/2))/(2*a)
-(b - (b^2 - 4*a*c)^(1/2))/(2*a)
Lets try to find the max of that matrix.
>> max(results)
??? Undefined function or method 'max' for input arguments of type 'sym'.
If you think about it, this should not surprise you since we do not know the values of the symbolic variables a,b and c and the results of max will depend on these values. For example
a=1;b=1;c=1
>> y=subs(results)
y =
-0.5000 - 0.8660i
-0.5000 + 0.8660i
>> max(y)
ans =
-0.5000 + 0.8660i
So for a=1;b=1;c=1, the second element of results is the maximum. However, for a=-1;b=1;c=1, the first element of results is the maximum:
>> a=-1;b=1;c=1;
>> y=subs(results)
y =
1.6180
-0.6180
>> max(y)
ans =
1.6180
Hope this helps, Mike
See Also
Categories
Find more on Symbolic Math Toolbox 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!