1 function [v,u] = rotate_cell(uIn)
2 % The function rotates and the flips over the off-diagaonal a 2x2 cell so that the
3 % largest value is in the lower left corner and largest valu on the
4 % diagonal is on the upper left corner.
6 % v = rotate_cell(uIn) will rotate permute the rows of matrix Uin.
7 % [v,u] = rotate_cell(~,n) will generate a nx4 matrix with random
8 % perumations of the row [1 2 3 4] and them permute them to correct order.
9 % Used for diagnostics.
11 % uIn - nx4 matrix whose rows will be permuted. Passing an integer as
12 % uIn will create testing values with size uIn x 4
14 % v - matrix with rows to be permuted
15 % u - optional matrix with created rows or original matrix.
24 % Optionally create matrix with rows [t00 t01 t10 t11]
25 % as perumatations of [4 3 2 1]
39 %rearrange so maximum value is in the first position, always.
40 %then put largest of diagonals in upper left.
42 %find location of largest element
43 [~,idx] = max(v(i,:));
47 %rotate to put largest first
58 %swap the diagonals to put largest in second place
60 %fprintf('Corner swap, i = %d \n',i)