Hi. I am trying to create a loop to multiply two matricies 40 times such that B*C=D1 and C*D1=D2 and B*D2=D3 and so on . I am very much new to matlab. Can anyone help me on this ?

2 ビュー (過去 30 日間)
I am trying to create a loop to multiply two matricies 40 times such that B*C=D1 and C*D1=D2 and B*D2=D3 and so on . I am very much new to matlab. Can anyone help me on this ?
  3 件のコメント
the cyclist
the cyclist 2014 年 11 月 1 日
Also, do you need to keep all the intermediate products, or just the final result?
mk_ballav
mk_ballav 2014 年 11 月 1 日
編集済み: mk_ballav 2014 年 11 月 1 日
The pattern is after you multiply by product of B*D by C then again have to multiply the product of C*(B*D) by B and simultaneously multiply thereafter products by C and B. I want all the intermediate steps as well.

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

採用された回答

Image Analyst
Image Analyst 2014 年 11 月 1 日
Try this:
clc;
b = randi(9, 2, 2)
c = randi(9, 2, 2)
D{1} = b * c;
for k = 2 : 5 % End wherever you want
theRemainder = rem(k, 2);
% Alternate multiplying by b or c
if theRemainder == 0
D{k} = c * D{k-1};
else
D{k} = b * D{k-1};
end
end
celldisp(D);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by