Assign some vector's values to an Identify matrix

Let's say we have the table A
>> A=eye(,5)
A =
Diagonal Matrix
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
0 0 0 0 0
and we also have the vector
x=[2 3 4 5 6]
how can I put the x values to the A matrix like this
A =
2 0 0 0 0
0 3 0 0 0
0 0 4 0 0
0 0 0 5 0
0 0 0 0 6
0 0 0 0 0

More Answers (0)

Categories

Products

Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!