简体   繁体   English

如何在Matlab的2列之间交换许多值

[英]How to swap a number of the values between 2 columns in Matlab

I have a matrix with the size of 10x100. 我有一个尺寸为10x100的矩阵。 How can I swap the values between column 1 and column 10 in the first 40% of the rows? 如何在行的前40%中的第1列和第10列之间交换值?

You can use: 您可以使用:

A = rand(10,100);

A(round(1:0.4*size(A,1)),[1,10]) = A(round(1:0.4*size(A,1)),[10,1]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM