Why do I receive an error when raising a symbolic matrix to the zeroth power in the Symbolic Math Toolbox?

2 views (last 30 days)
When I execute the following commands:
A = ones(3, 3);
A^0
I obtain the expected result:
ans =
1 0 0
0 1 0
0 0 1
However, when I convert "A" to a symbolic matrix, then raise it to the zeroth power:
A = sym(A);
A^0
I receive the following error:
??? Error using ==> sym.inv
Error, (in inverse) singular matrix

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
We have verified that there is a bug in the Symbolic Math Toolbox in the way that an error is generated when raising a symbolic matrix to the zeroth power.
To work around this issue, you can use an IF-ELSE statement to recognize this case, and use the EYE function to create the necessary identity matrix. For example, if your code is raising a symbolic matrix to the "n"th power, where "n" is an arbitrary real number, use the following construct:
if n~=0
B = A^n;
else
B = sym(eye(size(A)));
end

More Answers (0)

Products


Release

R14SP1

Community Treasure Hunt

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

Start Hunting!