MATLAB: How to generate a matrix as in the picture matlab matrix A is the matrix and n is an arbitrary number that larger than 3,thank you very much! Best Answer n = 6; % Let n = 6z = [-1 3 -3 1];m = numel(z);k = n-m+1;A = full(spdiags(ones(k,1)*z,0:m-1,k,n));other way with Communications System Toolbox:n = 6; % Let n = 6z = [-1 3 -3 1];A = convmtx(z,n-numel(z)+1); 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 QuestionHow to save matrix created in each iterationAdd a diagonal of zeros to a matrix in MATLABHow to implement the 3*3 matrix in a for loopCombining matrices, adding two matrices in into a bigger one.How to assemble the Matrix A for any number of nodesMatrix columns and rows manipulating with loop
Best Answer