arrays - sorting 3D matrix by using 2D matrix -


Hello, I'm trying to sort a 3D coordinate matrix (3 columns and unlimited rows) using sorting in a 2D coordinate matrix. (2 columns and unlimited rows):
  a = [x1 y1 z1; X2 y2 z2; Xn yn zn]; B = [xn yn; X1 y1; X2 y2];   

Example:

A = [87 45 47; 87 66 47; 80 40 48; 81 41 48; 87 45 48; 87 66 48; 69 39 4 9; 73 39 49; 79 40 49; 81 71 49; 86 67 49; 70 39 50; 74 38 50; 79 40 50; 82 70 50; 85 68 50; 71 39 51; 75 38 51;

B = [87 45; 87 45; 81 41; 80 40; 79 40; 79 40; 75 38; 74 38; 73 39; 71 39; 70 39; 69 39; 87 66; 87 66; 86 67; 85 68; 82 70; 81 71];

I would like to sort based on B, which means that I would like to always like A:

Anui = [xn yn zn; X1 y1 z1; X2 y2 z2] ;

This is an example of my data. Axyz is a matrix of coordinates and B is only xy.

Is there any way to do this or can someone try to help me?

Edit: I used the method proposed by January and its workings. Thanks and sorry if I have not provided enough information in my initial post.

If I understand it correctly, Rows want to be re-sorted as they are the first two columns of this matrix equals matrix b (hence match according to sequence) First of all, rows in B are not unique, so the solution will not be unique.

Nevertheless, an approach will be involved in sorting both rows to get the desired new order. The approach remains a few, but works like this:

First, A (:, 1: 2) and B : < / P> [~, orderA] = Sikross (A (:, 1: 2)); [~, Order b] = sortrose (b);

Then, get the order of the 'Inverse' action in the second sequence:

  [~, orderBinv] = sort (orderB);   

Now, to get the order of B to obtain the order of A (:, 1: 2) For, you sort and reverse sorting in this way:

  anui = a (order a (orderbiz), :)   

OK, so here we go What's done: Take reversal sorting so that a sorted version of B will result in the original form. Sorted B sorted a (:, 1: 2) (in the case of unique rows), so by applying this command to Sorting results by one gives us the desired results.


Then, for the given a (for the convenience of reading):

  87 87 80 81 87 87 69 73 79 81 86 70 74 79 82 85 71 75 45 66 40 41 45 66 39 39 40 71 67 39 38 40 70 68 39 38 47 47 48 48 48 48 49 49 49 49 49 50 50 50 50 50 51 51 >  

and b

  87 87 81 80 79 79 75 74 73 71 70 69 87 87 86 85 82 81 45 45 41 40 40 40 38 38 39 39 39 39 66 66 67 68 70 71   

Resulted as axis par <87> 87 87 79 79 75 74 73 71 70 69 87 87 86 85 82 81 45 45 41 40 40 38 38 39 39 39 39 66 66 67 68 70 71 47 48 48 48 49 50 51 50 49 51 50 49 47 48 49 50 50 49 < / Code>

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -