MATLAB: How to transform a matrix in his snake version matrix I'd want the code that transforms the matrix from A=[1 2 3; 4 5 6; 7 8 9; 10 11 12] to the matrix B=[1 2 3; 6 5 4; 7 8 9; 12 11 10] thanks Best Answer >> A=[1 2 3; 4 5 6; 7 8 9; 10 11 12]; B=[1 2 3; 6 5 4; 7 8 9; 12 11 10] A([2:2:size(A,1)],:)=fliplr(A([2:2:size(A,1)],:)); result=A isequal(result,B) % to check if you get the desired resultB = 1 2 3 6 5 4 7 8 9 12 11 10result = 1 2 3 6 5 4 7 8 9 12 11 10ans = logical 1>> Related SolutionsMATLAB: How to flip every 5th row and column in matrix >> M = repmat((1:12).',1,3)M = 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9 10 10 10 11 11 11 12 12 12>> M([4:6:end,6:6:end],:) = M([6:6:end,4:6:end],:)M = 1 1 1 2 2 2 3 3 3 6 6 6 5 5 5 4 4 4 7 7 7 8 8 8 9 9 9 12 12 12 11 11 11 10 10 10 MATLAB: How to double a vector and to the second part of it add a number R=[1; 2; 3; 4; 5; 6; 7; 8; 9; 10] R=[R;R+360] Related QuestionI have a matrix of 5 rows and 3 columns and i want to select only 1st 3rd and 4th row with all column using an array how to do it?whats the scriptHelp running Matlab scriptIs it possible to extract the values with a vector of indices for each row without using the for statement from the matrixHow to find a subset matrix in the main matrix and build a new matrixReplacing row values from another matrixHow to modify a matrix to change the entries >=0 and multiply it by 5 AND to change the entries <0 and add 2 to those entries
Best Answer