Rank of symbolic matrix is wrong (but too small, not too large)

4 vues (au cours des 30 derniers jours)
creepydog
creepydog le 4 Août 2021
Commenté : Walter Roberson le 21 Mar 2022
I get a wrong result using the sym/rank command. I'm aware of the limitations of this command as it does not simplify expressions (see: doc sym/rank). So it might fail to recognize linear dependencies and therefore overestimate the rank.
But in my example it computes a too low rank. sym/rank finds a singularity where there is none.
Consider this symbolic 3x3 matrix S:
clear
pi = sym(pi);
syms phi real
S = [cos(phi) cos(phi - 2*pi/3) cos(phi - 4*pi/3)
sin(phi) sin(phi - 2*pi/3) sin(phi - 4*pi/3)
1 1 1];
At the command line:
>> S
S =
[cos(phi), cos(phi - (2*pi)/3), cos(phi - (4*pi)/3)]
[sin(phi), sin(phi - (2*pi)/3), sin(phi - (4*pi)/3)]
[ 1, 1, 1]
This matrix is always regular (i.e. for any value of phi). This can be shown by computing the determinant of S, which is non-zero (and independent of phi).
>> simplify(det(S))
ans =
-(3*3^(1/2))/2
But the rank command returns 2 (should be 3):
>> rank(S)
ans =
2
inv(S) computes the correct inverse of S without any problem. Also try simplify(inv(S)*S), which returns the identity matrix as expected.
I've tested this on R2016b, R2018b, R2020b and R2021a.
In my opinion this behavior cannot be explained by the documented limitations and should be considered a bug.

Réponse acceptée

Prahlad Gowtham Katte
Prahlad Gowtham Katte le 15 Fév 2022
Hello,
This is a known issue and has been communicated with the internal staff and it would be considered for a fix in the future.
  2 commentaires
Scott Phillips
Scott Phillips le 21 Mar 2022
Has this bug been resolved yet? I'm getting similar errors
Walter Roberson
Walter Roberson le 21 Mar 2022
Still a problem in R2022a unfortunately.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by