Element wise multiplication to matrix in a "matrix array"?

2 ビュー (過去 30 日間)
K.E.
K.E. 2016 年 8 月 27 日
回答済み: Azzi Abdelmalek 2016 年 8 月 27 日
I have an array of matrix m such that
m1 = [1 2;3 4];
m2 = [2 7; 8 9];
m3 = [9 7; 8 91];
m = [m1 m2 m3]
m =
1 2 2 7 9 7
3 4 8 9 8 91
I also have a vector
v = [1 2 3];
such that i want the operations between v and m result in h such that
h = [1*m1 2*m2 3*m3] = [h1 h2 h3];
From h i want to extract h1 h2 and h3 out(, how?) such that
h1*A*h1'
h2*A*h2'
h3*A*h3'
and where A is a 2 by 2 matrix, say [10 11; 12 13].
h1*h1', h2*h2', h3*h3'.
The reason i want to do this in array is because i have a lot of matrix mi so I want to avoid for loop by vectorization.
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2016 年 8 月 27 日
What is A?
K.E.
K.E. 2016 年 8 月 27 日
just a 2 by 2 matrix.

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

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 8 月 27 日
m1 = [1 2;3 4];
m2 = [2 7; 8 9];
m3 = [9 7; 8 91];
m = [m1 m2 m3]
[n1,n2]=size(m1)
v=[1 2 3]
M=reshape(m,n1,n2,[])
B=bsxfun(@times,M,reshape(v,1,1,[]))
out=B(:,:)

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by