MatLab Swap Rows or Cols 交换行或列

简介:

Matlab是矩阵运算的神器,所以可以很轻易的交换任意行或列,而且写法非常简洁,如下所示:

a = [1 2 3; 4 5 6; 7 8 9];
b = a;
b(:,[1;2]) = b(:,[2;1]); % Swap col 1 and 2
c = a;
c([1;2],:) = c([2;1],:); % Swap row 1 and 2

本文转自博客园Grandyang的博客,原文链接:交换行或列MatLab Swap Rows or Cols ,如需转载请自行联系原博主。

相关文章
Matlab:成功解决Index must be a positive integer or logical
Matlab:成功解决Index must be a positive integer or logical
Matlab:成功解决Index must be a positive integer or logical
|
机器学习/深度学习
Matlab中解决出现的错误使用 svmtrain (line 234) Y must be a vector or a character array.问题
Matlab中解决出现的错误使用 svmtrain (line 234) Y must be a vector or a character array.问题
Matlab中解决出现的错误使用 svmtrain (line 234) Y must be a vector or a character array.问题
[LeetCode] K-diff Pairs in an Array 数组中差为K的数对
Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array.
1523 0