divide a matrix per a vector

조회 수: 2 (최근 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 CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by