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

4 次查看(过去 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