divide a matrix per a vector

11 ビュー (過去 30 日間)
Paul Rogers
Paul Rogers 2019 年 12 月 11 日
コメント済み: Paul Rogers 2019 年 12 月 12 日
Hi, I have a matrix A(7x1001) and a matrix B(1x7).
I'd like to divide the first row of A for the first colum(element) of B,
second row of A for the second column in B, and so on.
A and B are in attached

採用された回答

per isakson
per isakson 2019 年 12 月 11 日
Try
C = A ./ reshape( U2, [],1 );
  5 件のコメント
Guillaume
Guillaume 2019 年 12 月 12 日
Oh, you're on a very old version, which doesn't have implicit expansion:
C = bsxfun(@rdivide, A, B(:));
However, again, why isn't B a column vector (7x1) instead of a row vector (1x7)? This would avoid the transpose/reshape and would make it consistent with the shape of A.
Paul Rogers
Paul Rogers 2019 年 12 月 12 日
thanks man it's this!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

製品


リリース

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by