From: nick on
Hi all,

Could someone please give me a hand for this simple question?

I want to multiply colum by colum of the two matrices.

For example: matrix X has the size (4,3) and matrix Y has the size (1,3). Is there any single Matlab command to produce a matrix Z in the following format:

Z = [X(:,1)*Y(1) X(:,2)*Y(2) X(:,3)*Y(3)]

Thanks heap for your inputs.

Nick
From: Faraz Afzal on
nick <nghiango79(a)gmail.com> wrote in message <1124078130.14069.1277687570117.JavaMail.root(a)gallium.mathforum.org>...
> Hi all,
>
> Could someone please give me a hand for this simple question?
>
> I want to multiply colum by colum of the two matrices.
>
> For example: matrix X has the size (4,3) and matrix Y has the size (1,3). Is there any single Matlab command to produce a matrix Z in the following format:
>
> Z = [X(:,1)*Y(1) X(:,2)*Y(2) X(:,3)*Y(3)]
>
> Thanks heap for your inputs.
>
> Nick

Hey Nick

To my knowledge there is none.
You can make use of a for loop and save it in an mfile , therby u can achieve it in one command.

You know how to generalize it with for loop..don't you ?
Regards
Faraz
From: Roger Stafford on
nick <nghiango79(a)gmail.com> wrote in message <1124078130.14069.1277687570117.JavaMail.root(a)gallium.mathforum.org>...
> Hi all,
>
> Could someone please give me a hand for this simple question?
>
> I want to multiply colum by colum of the two matrices.
>
> For example: matrix X has the size (4,3) and matrix Y has the size (1,3). Is there any single Matlab command to produce a matrix Z in the following format:
>
> Z = [X(:,1)*Y(1) X(:,2)*Y(2) X(:,3)*Y(3)]
>
> Thanks heap for your inputs.
>
> Nick

Z = bsxfun(@times,X,Y);

Roger Stafford
From: nick on
This is what I am looking for. Thanks very much Roger.
From: Steve Amphlett on
nick <nghiango79(a)gmail.com> wrote in message <1489283667.14448.1277695292924.JavaMail.root(a)gallium.mathforum.org>...
> This is what I am looking for. Thanks very much Roger.

Before bsxfun there was repmat.
Before repmat there was ones.