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 Ansichten (letzte 30 Tage)
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 Kommentare
the cyclist
the cyclist am 1 Nov. 2014
Also, do you need to keep all the intermediate products, or just the final result?
mk_ballav
mk_ballav am 1 Nov. 2014
Bearbeitet: mk_ballav am 1 Nov. 2014
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 1 Nov. 2014
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);

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by