Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Matrix / column vector division

Subject: Matrix / column vector division

From: Paul

Date: 7 Jul, 2011 17:30:14

Message: 1 of 4

I'm sure this is routine, but if I have a matrix

a b
c d

and a column vector:

e
f

I need to divide each column of the matrix by the vector (element by element) to yield

a/e b/e
c/f d/f

What is the proper syntax?... thanks!

Subject: Matrix / column vector division

From: Matt J

Date: 7 Jul, 2011 17:37:10

Message: 2 of 4

"Paul " <palex71@hotmail.com> wrote in message <iv4qf6$2up$1@newscl01ah.mathworks.com>...
>
> I need to divide each column of the matrix by the vector (element by element) to yield
>
> a/e b/e
> c/f d/f
>
> What is the proper syntax?... thanks!

bsxfun(@rdivide,abcd,ef)

Subject: Matrix / column vector division

From: Roger Stafford

Date: 7 Jul, 2011 17:40:24

Message: 3 of 4

"Paul " <palex71@hotmail.com> wrote in message <iv4qf6$2up$1@newscl01ah.mathworks.com>...
> I'm sure this is routine, but if I have a matrix
>
> a b
> c d
>
> and a column vector:
>
> e
> f
>
> I need to divide each column of the matrix by the vector (element by element) to yield
>
> a/e b/e
> c/f d/f
>
> What is the proper syntax?... thanks!
- - - - - - - - -
  Read documentation for bsxfun.

Roger Stafford

Subject: Matrix / column vector division

From: Paul

Date: 7 Jul, 2011 17:44:11

Message: 4 of 4

"Matt J" wrote in message <iv4qs6$49r$1@newscl01ah.mathworks.com>...
> "Paul " <palex71@hotmail.com> wrote in message <iv4qf6$2up$1@newscl01ah.mathworks.com>...
> >
> > I need to divide each column of the matrix by the vector (element by element) to yield
> >
> > a/e b/e
> > c/f d/f
> >
> > What is the proper syntax?... thanks!
>
> bsxfun(@rdivide,abcd,ef)

Perfect... thanks!

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us