Matrix Multiplication using for loop

Suppose I have following 7 matrcies defined as
Matrix A
x1=1st Matrix
x2=2nd Matrix
x3=3rd Matrix
x4=4th Matrix
x5=5th Matrix
x6=6th Matrix
So I want to multiply 1st element of matrix A with 1st element of x1
2nd element of matrix A with 1st element of x2
3rd element of matrix A with 1st element of x3
4th element of matrix A with 1st lement of x4
5th element of matrix A with 1st element of x5
6th element of matrix A with 1st element of x6
And add the above result
How can I use for loop ?

3 件のコメント

madhan ravi
madhan ravi 2018 年 11 月 28 日
you don‘t need a loop to do that
Jay Mistry
Jay Mistry 2018 年 11 月 28 日
yes I know that but I have a task to use loop
madhan ravi
madhan ravi 2018 年 11 月 28 日
so give an example of your matrices to better understand

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

回答 (1 件)

madhan ravi
madhan ravi 2018 年 11 月 28 日

0 投票

An example:
A=A(:);
m{1}=rand(3);
m{2}=rand(3);
m{3}=rand(3);
m{4}=rand(3);
m{5}=rand(3);
m{6}=rand(3);
matrix=cell(1,6) % 6 number of matrices
for i=1:6
matrix{i}=A(i)*[m{i}]; %elements of A multiplied to each matrix
end
celldisp(matrix)

1 件のコメント

madhan ravi
madhan ravi 2018 年 11 月 28 日
If it was what you were looking for make sure to accept the answer else let know

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

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2018 年 11 月 28 日

コメント済み:

2018 年 11 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by