Перемещение столбца:
%# Columns before destination are shifted back.
%# Matrix size unchanged.
data = rand(100);
desiredCol = 5;
destinationCol = 15;
data = [ data(:,1:desiredCol-1) ...
data(:,desiredCol+1:destinationCol) ...
data(:,desiredCol) ...
data(:,destinationCol+1:end) ];
Замена двух столбцов:
%# Matrix size unchanged.
temp = data(:,destinationCol);
data(:,destinationCol) = data(:,desiredCol);
data(:,desiredCol) = temp;
Перемещение с перезаписью:
%# Destination is not preserved.
%# Matrix size decreases by 1.
data(:,destinationCol) = data(:,desiredCol);
data(:,desiredCol) = [];