Reputation: 179
this is my code,i want to put the result of diag in a matrix 3*3 in Matlab,how to create it?
a=magic(9);
b=diag(a);
i want to put the result of b in a matrix 3*3
Upvotes: 0
Views: 105
Reputation: 36442
c = reshape(b,[3,3])
will reshape your 1x9 matrix b
into a 3x3 matrix c
Upvotes: 2