Devision of matrix by matrix

6 ビュー (過去 30 日間)
Scragmore
Scragmore 2011 年 10 月 21 日
Hi, Please excuse total n00b here.
I am after devision of matrix by a second matrix, example;
x = [4; 8; 12; 16; 20];
y = [2 4];
I want x/y to give
ans = [2 1; 4 2; 6 3; 8 4; 10 5]
Thanks
Ad

採用された回答

the cyclist
the cyclist 2011 年 10 月 21 日
The bsxfun() command will automatically replicate arrays across the dimensions you need:
bsxfun(@rdivide,x,y)
I recommend reading "doc bsxfun" to get an understanding of the function.
  2 件のコメント
Scragmore
Scragmore 2011 年 10 月 21 日
Thanks for the quick response. It was just what the doctor ordered. Yes I threw it straight at the help file to get more of an explanation.
Thanks again.
AD
Andrei Bobrov
Andrei Bobrov 2011 年 10 月 21 日
x*(1./y)

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

その他の回答 (0 件)

カテゴリ

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