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:
element-by-element multiplication

Subject: element-by-element multiplication

From: Natalie Sin Hwee

Date: 19 Jun, 2010 18:19:05

Message: 1 of 5

Dear Mathwork users,

If i have two matrices,

A=magic(3)
B=magic(3)


a =[8 1 6; 3 5 7; 4 9 2]
a =
     8 1 6
     3 5 7
     4 9 2

b =[8 1 6; 3 5 7; 4 9 2]
b =
     8 1 6
     3 5 7
     4 9 2

What multiplication method do i use (e.g. cross/dot product) if i want to multiply each element by each element to result in a 3x3 matrix to get:

c= [54, 1 36; 9 25 49; 16 81 4]
c =
    54 1 36
     9 25 49
    16 81 4


Thank you ^^
Natalie

Subject: element-by-element multiplication

From: Matt Fig

Date: 19 Jun, 2010 18:27:05

Message: 2 of 5

magic(3).*magic(3)

Subject: element-by-element multiplication

From: John D'Errico

Date: 19 Jun, 2010 18:30:22

Message: 3 of 5

"Natalie Sin Hwee " <sin.ng09@imperial.ac.uk> wrote in message <hvj1mp$p54$1@fred.mathworks.com>...
> Dear Mathwork users,
>
> If i have two matrices,
>
> A=magic(3)
> B=magic(3)
>
>
> a =[8 1 6; 3 5 7; 4 9 2]
> a =
> 8 1 6
> 3 5 7
> 4 9 2
>
> b =[8 1 6; 3 5 7; 4 9 2]
> b =
> 8 1 6
> 3 5 7
> 4 9 2
>
> What multiplication method do i use (e.g. cross/dot product) if i want to multiply each element by each element to result in a 3x3 matrix to get:
>
> c= [54, 1 36; 9 25 49; 16 81 4]
> c =
> 54 1 36
> 9 25 49
> 16 81 4
>
>
> Thank you ^^
> Natalie

Well, I don't know of ANY operator that will give you the
result you show, since 8*8 = 64, not 54.

If perhaps you really meant 64 there, then you might find
the .* operator of value.

help times

John

Subject: element-by-element multiplication

From: Matt Fig

Date: 19 Jun, 2010 18:30:22

Message: 4 of 5

Also, you really should get used to using MATLAB's help facilities. For example, if you had done:

docsearch('element-by-element')

you would have figured it out!

Subject: element-by-element multiplication

From: John

Date: 19 Jun, 2010 18:59:46

Message: 5 of 5

a.*b

and 8 x 8 is 64


"Natalie Sin Hwee " <sin.ng09@imperial.ac.uk> skrev i meddelelsen
news:hvj1mp$p54$1@fred.mathworks.com...
> Dear Mathwork users,
>
> If i have two matrices,
>
> A=magic(3)
> B=magic(3)
>
>
> a =[8 1 6; 3 5 7; 4 9 2]
> a =
> 8 1 6
> 3 5 7
> 4 9 2
>
> b =[8 1 6; 3 5 7; 4 9 2]
> b =
> 8 1 6
> 3 5 7
> 4 9 2
>
> What multiplication method do i use (e.g. cross/dot product) if i want to
> multiply each element by each element to result in a 3x3 matrix to get:
>
> c= [54, 1 36; 9 25 49; 16 81 4]
> c =
> 54 1 36
> 9 25 49
> 16 81 4
>
>
> Thank you ^^
> Natalie

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