MATLAB: Create diagonal matrix zeros diagMATLABmatrix manipulation I'm trying to create a matrix like this: I'm able to create one matrix with a=diag(1:10) and another with b=(1:10)+(0:9)' But I don't know how to combine them together to get A. Thanks for your help Best Answer a = diag(1:10);a(1,:) = 1:10;a(:,1) = 1:10; Related SolutionsMATLAB: Change diagonal place a= magic(3)a = 8 1 6 3 5 7 4 9 2>> b=a;>> for i =2:size(a,1)b(i,1:i)= fliplr(a(i,1:i));endbb = 8 1 6 5 3 7 2 9 4 MATLAB: Access Diagonal Matrix Element As it is a rectangular matrix you will get 15 diagonal(i=j) elements. If you have a square matrix of size nxn, you will get n diagonal elements. Related QuestionExtracting matrix diagonal with diag(A)Left eigenvectors using eigs with sparse matricesIs diag faster than zeros
Best Answer