COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### 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

```magic(3).*magic(3)
```
 0

```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

```"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

```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

4 Replies
299 Views

Similiar Articles:

7/22/2012 6:08:43 PM