How to multiply a subset of matrix by a column from another matrix?
2 ビュー (過去 30 日間)
古いコメントを表示
I have an array of 128x9252 and I would like to group them as
A1 = (:,1:257)
A2 = (:,258,514)
…
A36 = (:,8996:9252)
which will then be multiplied (.*) by y with the corresponding columns - y(:,1), y(:,2), y(:,3), etc.
This is what I want mathematically, A1 * y(:,1), A*y(:,2)), and so on.
How can I go about doing this?
This is what I have so far, but I keep getting an error saying 'Unable to perform assignment because the size of the left side is 128-by-1 and the size of the right side is 128-by-257.' and I'm not sure where the error is.
A = rand(128,9252);
B = zeros(128,257);
for m = 1:257
for n = 1:36
B(:,m) = A(:,257*(n-1)+1:257*n);
end
end
0 件のコメント
採用された回答
Matt J
2022 年 3 月 23 日
編集済み: Matt J
2022 年 3 月 23 日
B = pagemtimes( reshape(A,128,257,[]) , reshape(y,257,1,[]) ) ;
B=squeeze(B);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!