element-by-element multiplication

  • Follow


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 
0
Reply Natalie 6/19/2010 6:19:05 PM

magic(3).*magic(3)
0
Reply Matt 6/19/2010 6:27:05 PM


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!
0
Reply Matt 6/19/2010 6:30:22 PM

"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
0
Reply John 6/19/2010 6:30:22 PM

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 

0
Reply John 6/19/2010 6:59:46 PM

4 Replies
299 Views

(page loaded in 0.243 seconds)

Similiar Articles:













7/22/2012 6:08:43 PM


Reply: