Symbolic matrices multipleid incorrectly
3 次查看(过去 30 天)
显示 更早的评论
Hello!
I have matrix equation:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/611490/image.png)
When I try to find X I get incorrect result:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/611495/image.png)
Check does not pass:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/611500/image.png)
I attach a .mat file with an example. There is a ST structure with M1 and M2 fields in a .mat file. Both are symbolic matrices.
Code for testing.
X = ST.M1^-1 * ST.M2;
disp(ST.M1 * X - ST.M2)
The invertible matrix of M1 is correct. The condition number of M1 is 1. Where is the problem?
0 个评论
回答(1 个)
Paul
2021-5-8
What was your actual check that the result does not pass? Maybe you need to simplify() the result?
M1=sym('m1',[2 2]);
M2=sym('m2',[2 2]);
X=M1^-1*M2;
D = M1*X - M2 % looks non-zero
simplify(D) % is zero
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!