MATLAB: Fitting N(N-1) points on an NxN matrix MATLABmatrix Suppose I have an N(N-1) vector that corresponds to each non-diagonal entry of an NxN matrix. Is there anyway that I can encode that onto my matrix? i.e. For n=3, given [ 2 3 4 5 6 7 ] we obtain [0 4 6 ; 2 0 7 ; 3 5 0]? Best Answer % Say your given vector is:X = [ 2 3 4 5 6 7 ];% Now to make the matrix.L = (1 + sqrt(1+4*length(X)))/2;F = double(~eye(L));F(~eye(L)) = X Related SolutionsMATLAB: How to Assemble this matrix n = 4; %for examplemain_diagonal = [ [-4, repmat(-3,1,n-2), -4], repmat([-5, repmat(-4,1,n-2), -5], 1, 2), [-6, repmat(-5,1,n-2), -6] ];N = length(main_diagonal);m = diag(ones(1, N-4), -4) + diag(ones(1, N-1), -1) + diag(main_diagonal) + diag(ones(1, N-1), 1) + diag(ones(1, N-4), -4) MATLAB: How to Assemble the matrix shown in the image on Matlab for any number of nodes n = 4; %for examplemain_diagonal = [ [-4, repmat(-3,1,n-2), -4], repmat([-5, repmat(-4,1,n-2), -5], 1, 2), [-6, repmat(-5,1,n-2), -6] ];N = length(main_diagonal);m = diag(ones(1, N-4), -4) + diag(ones(1, N-1), -1) + diag(main_diagonal) + diag(ones(1, N-1), 1) + diag(ones(1, N-4), -4) Related QuestionI dont know how to write this code in one command can someone help meHelp regarding ((differen​tiation-1)​^n)*x^nFunction that returns an NxN matrixFlip half of matrix over the diagonal to make a symmetric matrixElemental matrix multiplication [NxN] and [1xn] into [NxNxn]
Best Answer