Question: How to change only the diagonal values in matrix?

Hi, may I know how do I change only the diagonal to certain values please? Thank you.

with(LinearAlgebra):
M:=RandomMatrix(6):
G:=DiagonalMatrix(RandomVector(6)):

Question 1: How do I change the diagonal part to a certain value for example 'a'?
Question 2: How do I change the diagonal part to the vector G?

 

This has been branched into the following page(s):
Please Wait...