divide a matrix per a vector

5 Ansichten (letzte 30 Tage)
Paul Rogers
Paul Rogers am 11 Dez. 2019
Kommentiert: Paul Rogers am 12 Dez. 2019
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

Akzeptierte Antwort

per isakson
per isakson am 11 Dez. 2019
Try
C = A ./ reshape( U2, [],1 );
  5 Kommentare
Guillaume
Guillaume am 12 Dez. 2019
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 am 12 Dez. 2019
thanks man it's this!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by