Assign some vector's values to an Identify matrix
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Operating on Diagonal Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!