how do i multiply n number of matrix for 2x2 with the symboic output

3 次查看(过去 30 天)
hi how do i use my symbolc output results and do a matrix multiplication for a 2x2 matrix?thank you in advance
  5 个评论
grace lim
grace lim 2022-2-20
编辑:grace lim 2022-2-20
im usng symbolic to simplify symbols ,theres error,'M ' is not a variable
is there another way to solve?
what does M means?

请先登录,再进行评论。

回答(2 个)

grace lim
grace lim 2022-2-20
i tried this way but there is no output
E = ABCD
for n=1:9
E = E*ABCD;
end
  1 个评论
Walter Roberson
Walter Roberson 2022-2-20
I am not going to type in your equations from your image, so I will illustrate with some examples:
syms h0 h1 h2 h3
A = 1/(h0+h1)
A = 
B = h0/(h0+h2)
B = 
C = h2*h3/h0
C = 
D = h3 - h1
D = 
ABCD = [A B; C D]
ABCD = 
E = ABCD
E = 
for n = 1:9
E = E*ABCD;
end
E
E = 
If you need to see the results of each multiplication in turn, then change E = E*ABCD; to become E = E*ABCD without the semi-colon

请先登录,再进行评论。


grace lim
grace lim 2022-2-21
thank you,
how about if i wnt to do 2 matrix multiplication for n number of times?
do i do it this way?
E=[A B;CD]
F={A B;C D]
EF=E*F
for n = 1:9
E = E*ABCD;
end
  3 个评论
grace lim
grace lim 2022-2-21
sorry ,what i meant was:
syms ....
h11..
h12..
h21...
h22...
E=[A B;C D]
...
F=[A B;C D]
..
EF=E*F
the 2 matrix ABCD are different
then,
for n = 1:9
E = E*ABCD;
end
Walter Roberson
Walter Roberson 2022-2-21
How does ABCD differ from the [A B;C D] you assign to E, and how does that differ from the [A B;C D] that you assign to F?
Or are you changing A B C D between those points?
Anyhow... go ahead with your code. Just make sure you get right how many multiplications you want to do.
If we call the new A B C D as nA, nB, nC, nD then do you want [nA, nB; nC, nD] * ABCD^9 or do you want [nA, nB; nC, nD] * ABCD^10 ? Your current code would give [nA, nB; nC, nD] * ABCD^9 . In the special case where nA, nB, nC, nD are the same as A, B, C, D, then nA, nB; nC, nD] * ABCD^9 would be the same as ABCD^10

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by