필터 지우기
필터 지우기

how to swap rows of a matrix using command linalg::swapRow(A, 1, 2)

조회 수: 13 (최근 30일)
i need to swap two rows of a matrix.. how can i use the command linalg::swapRow(A, 1, 2)

채택된 답변

Walter Roberson
Walter Roberson 2017년 1월 3일
feval(symengine, 'linalg::swapRow', A, 1, 2)
The output of this will be a symbolic matrix. If your matrix is numeric, then you should double() the result of the feval() to get back to numeric.
However... unless you are poking into the MuPAD engine, you are better off writing a small function:
function A = swapRow(A, row1, row2)
A([row2, row1], :) = A([row1, row2], :);

추가 답변 (1개)

Neel Shah
Neel Shah 2019년 11월 1일
i want to swap rows of 3*3 matrix
i.e. first row become last
second row become second last
  댓글 수: 4

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Operations and Transformations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by