symbolic variable
2 次查看(过去 30 天)
显示 更早的评论
'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 个评论
采纳的回答
Walter Roberson
2011-3-8
re=solve(GG); will return symbolic numbers. You need to apply double() to the symbolic numbers to convert them to floating point numbers.
0 个评论
更多回答(1 个)
Mike
2011-3-8
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!