MATLAB: A is a matrix , what does this statement A([1,end],[1,end]) mean arrayfunctionindexingmatrix The result of this command gives the 4 corners of the matrix, but can't figure out how that command works Best Answer That's equivalent to:[A(1,1), A(1,end);... A(1,end), A(end,end)] https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html - read above linear indexing. Related SolutionsMATLAB: How to add a row and column to a matrix One easy option is to do this for rows and columns separatelyA = [1 2 3 ; 4 5 6 ; 7 8 9]x = 3 ; % add a row/column of ones before this row/columnA(end+1, :) = 1 % add row add the endA([x end], :) = A([end x], :) % swap the x-th and last row% do the same for columnsA(:, end+1) = 1A(:, [x end]) = A(:, [end x]) MATLAB: Repeat last row at the end of matrix B = [A; A(end,:)] ; Related QuestionUnderstanding indexing and the colon operatorFor-end statementsExtracting elements of a matrix in the first row and even columns“end-1” as parameter
Best Answer