Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Instant Grammar Checker - Correct all grammar errors and enhance your writing

What's The REAL Secret To First Date Success With a Woman? Click Here To Find Out

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

29,960 questions

39,175 answers

573 users

How to multiply elements of two matrices in R

Booking.com | Official site | The best hotels, flights, car rentals & accommodations


71 views
asked Jul 7, 2021 by avibootz
edited Jul 7, 2021 by avibootz

1 Answer

0 votes
vec <- c(1, 2, 3, 1, 0, 2, 3, 1, 1)
m1 <- matrix(vec, nrow = 3, ncol = 3)
  
vec <- c(2, 1, 3, 0, 0, 1, 2, 1, 0)
m2 <- matrix(vec, nrow = 3, ncol = 3)
 
mul <- m1 * m2
   
print(m1)
print(m2)
print(mul)
  
  
  
    
    
# run:
#
#      [,1] [,2] [,3]
# [1,]    1    1    3
# [2,]    2    0    1
# [3,]    3    2    1
#      [,1] [,2] [,3]
# [1,]    2    0    2
# [2,]    1    0    1
# [3,]    3    1    0
#      [,1] [,2] [,3]
# [1,]    2    0    6
# [2,]    2    0    1
# [3,]    9    2    0
#

 


Protect Your Privacy - Download VPN


answered Jul 7, 2021 by avibootz

Related questions

1 answer 57 views
1 answer 53 views
53 views asked Jul 7, 2021 by avibootz
1 answer 50 views
50 views asked Jul 7, 2021 by avibootz
1 answer 73 views
1 answer 43 views
43 views asked Jul 3, 2021 by avibootz
...