Slip 24 - E) Write a script in R to create two vectors of different lengths and give these vectors as input to array and print Multiplication of those matrices.

Solution:

v1<-c(10,20,30,40)
v2<-c(2,3,4)
matrix1=array(c(v1,v2),dim=(c(2,2,2)))
print(matrix1)
matrix2=array(c(v2,v1),dim=(c(2,2,2)))
print(matrix2)
matrix1*matrix2

Post a Comment

0 Comments