Preserve the order of matrix when doing symbolic matrix multiplication
5 views (last 30 days)
Show older comments
Hi community,
I have been trying to use Matlab to do a large matrix multiplication using the symbolic tool. However, I found that the result it gave me is confusing in the order of matrices. Searched the mathwork forums and found a similar question without anwers:
So I decided to raise a new one and see if anyone knows the answer.
Problem I encounter is,
I define symbolic matrix as
A = sym('A', [1,1]);
B = sym('B',[1,1]);
and calculate
C = B*A,
and matlab will give me the answer C = A01*B01 which isn't the right order. The problem seems to root in the fact that matlab see the symbols as scalars when defined the dimension of [1,1], but I have to do this as my entire matrix is too big (38*38) so if I do dimension more than 1, it is very difficult to extract the matrix from the result.
Is there a way to force the order when doing multiplication? If not, could someone suggest other tools that can do this please?
Thanks in advance!
0 Comments
Accepted Answer
Walter Roberson
on 8 Mar 2021
This is not possible in any released versions.
It might be possible in a future version.
In all released versions, individual symbolic variables are always treated as scalars, and then the internal sorting rules designed to detect duplicate expressions come into play to re-order the names.
5 Comments
Walter Roberson
on 16 Feb 2022
Note that as of R2021a, defining symbolic matrix became possible. R2021a was released a couple of weeks after the question was asked, so as of the time the question was asked, no released version handled the task, only prerelease
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!