symbolic variable
Mostra commenti meno recenti
'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'.
Risposta accettata
Più risposte (1)
Mike
il 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
1 Commento
Hassan
il 8 Mar 2011
Categorie
Scopri di più su Symbolic Math Toolbox in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!