Element wise multiplication to matrix in a "matrix array"?
1 回表示 (過去 30 日間)
古いコメントを表示
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.
回答 (1 件)
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(:,:)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!