Divide elements between 2 matrices

13 ビュー (過去 30 日間)
N.
N. 2016 年 4 月 10 日
編集済み: Azzi Abdelmalek 2016 年 4 月 10 日
I have a matrix
M1 =[4 3 6 8 1 10 5 2 9 4 5 6
1 10 3 9 4 2 5 7 6 5 4 3
9 5 1 7 8 10 3 4 2 6 5 1];
M2 =[1 6 3 5
3 5 9 6
2 1 9 5];
If it is column 1, 5, or 9 in M1 then divide by column 1 in M2 If it is column 2, 6, or 10 in M1 then divide by column 2 in M2 If it is column 3, 7, or 11 in M1 then divide by column 3 in M2 If it is column 4, 8, or 12 in M1 then divide by column 4 in M2
and it will give an output of a matrix 3x12
output =[4 0.5 2 1.6 1 1.66667 1.66667 0.4 ...
0.33 2 0.33 1.5 1.33 0.4 0.5556 1.116 ...]
.
.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 10 日
編集済み: Azzi Abdelmalek 2016 年 4 月 10 日
M1 =[4 3 6 8 1 10 5 2 9 4 5 6
1 10 3 9 4 2 5 7 6 5 4 3
9 5 1 7 8 10 3 4 2 6 5 1];
M2 =[1 6 3 5
3 5 9 6
2 1 9 5];
[n,m]=size(M1);
a=reshape(M1,n,4,[]);
b=bsxfun(@rdivide, a,M2);
out=b(:,:)
  1 件のコメント
N.
N. 2016 年 4 月 10 日
Thank you so much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by