I have a nx23 matrix which I am looping through to get two separate variables X and Y (each of them being an nx1 column vector) but X and Y can never be the same column in the matrix. I'm using a nested For Loop since the looping has to happen at different rates, i.e. When X is the 1st column of the matrix, then the value of Y has to loop through the remaining 22 columns of the matrix (columns 2:23). Once Y has looped through all the columns, the value of X changes to the 2nd column of the matrix, and Y again loops through the remaining 22 columns. However, Y now has to start at column 1, skip column 2 (Y not equal to X), and continue through the rest of the columns. This continues until X equals the last column of the matrix.
The problem I have is that when Y=X and Y skips to the next column, the value of Y is repeated in the next loop. So when k=1, then the value of i = 2,2,3......23. When k=2, the value of i = 1,2,3,3,4......23, etc.
How do I prevent the repitition?
X = Institution_data(1:784,k);
Y = Institution_data(1:784,i);