Hi. I have a matrix :
x = [ 6.5 7 23 24 25]
6.5000 7.0000 23.0000 24.0000 25.0000
However, the numbers inside matrix x are not in the correct spots. I need to move some of them. In order to find out which ones to move, I have to look at another matrix which is called c and c equals to:
c = [ 1 2 3 4 5 ;
3 2 4 1 5]
1 2 3 4 5
3 2 4 1 5
I want to write a code which can detect which columns in matrix c do not have the same numbers in its two rows. For example in matrix c the answer is 1st, 3rd, and 4th columns. Following is what I have done.
y = find(c(1,:)~=c(2,:));
Now this line of code helps me to find where in numbers do not match.
Now I want a code which can apply the findings of y to swap the values in matrix x.
In other words, the out put of the code that I am looking for should give me
J = blahblah(x);
J = [ 24 7 6.5 23 25];
This is very important and I have no clue how to do it.
Any help would be appreciated.