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!