Is there any way to represent symbolic variables as I write from left to right?

1 回表示 (過去 30 日間)
Ahmad
Ahmad 2022 年 2 月 15 日
編集済み: Paul 2022 年 2 月 19 日
As you know in Matrix manipulation you're not allowed to change the order of Matrix. for example AB # BA (the commulative law is usually broken).
I was wondering if there was a way to represent the below matrix multiplication?
How can I modify this simple code to output the correct matrix ruls? ie change (BC/A) to (C/A)*B
syms I A B C D
sympref('MatrixWithSquareBrackets',true);
E=[1 0 ; -C/A 1]
E = 
F=[A B ; C D]
F = 
X=E*F
X = 
Thanks a bunch!

採用された回答

Paul
Paul 2022 年 2 月 16 日
Since R2021a, one can define symbolic matrices. I haven't really used them too much and so don't know how to get any further than what is shown below. I'm surprised Matlab won't carry out the multiplication of the block matrices. Maybe there is another command that will do so.
syms I [2 2] matrix
syms A [2 2] matrix
syms B [2 2] matrix
syms C [2 2] matrix
syms D [2 2] matrix
E = [I zeros(2);-C*inv(A) I]
E = 
F = [A B;C D]
F = 
G = E*F
G = 
  5 件のコメント
Walter Roberson
Walter Roberson 2022 年 2 月 16 日
You cannot. Block operations like that are not supported.
Perhaps I should not say "cannot", but rather "no method is provided". There might hypothetically be some way involving using mapSymType or similar operations.
Paul
Paul 2022 年 2 月 18 日
編集済み: Paul 2022 年 2 月 19 日
That's too bad that block matrix multiplication isn't supported. Maybe that's coming in a future release.
It would also be cool if the identity matrix and the zero matrix could be created as special symmatrix constants with specified dimensions to be used in equations such as above.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSymbolic Variables, Expressions, Functions, and Preferences についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by