Sort rows of a cell array using given indexes

Simo Os

We are given a cell array Ref_M of size m x n, and a vector IND of length m.

IND(i) contains the number of non-empty cells in the ith row of Ref_M. The purpose is to organize the lines in the cell array Ref_M based on the value in the IND vector from the largest value to the smallest.

Given:

Ref_M = [2x2 double]    [2x2 double]    []
        [2x2 double]     []             [] 
        [2x2 double]    [2x2 double]    []
        [2x2 double]    [2x2 double]    [2x2 double]

IND = [ 2 1 2 3]

The result should be:

New_Ref_M = [2x2 double]    [2x2 double]    [2x2 double]
            [2x2 double]    [2x2 double]    []
            [2x2 double]    [2x2 double]    []
            [2x2 double]    []              [] 

Also, is there a method to organize the cell array Ref_M lines without using the given vector of indexes, IND?

Mateen Ulhaq

Try sort().

[B, transform] = sort(IND, 'descend');
New_Ref_M = Ref_M(transform, :);

You can determine IND on your own using:

IND = sum(~cellfun('isempty', Ref_M), 2);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to sort elements in array without changing other elements indexes?

From Dev

Selecting rows from an HDFStore given list of indexes

From Dev

comparing array indexes or multi-dimentional array rows php

From Dev

Fastest way to sort an array by a separate array of indices/indexes

From Dev

How to get the Sudoku 2D-array index, given its "sub-grid" and "cell-in-the-sub-grid" indexes?

From Dev

Unique Rows for a cell array

From Dev

Replace elements in an array whose indexes do not match the given indexes

From Dev

Combine 2 rows in a cell array

From Dev

Find last cell with values using indexes

From Dev

How to shuffle the rows in a cell array

From Dev

Swift returning the indexes that will sort an array (similar to numpy argsort)

From Dev

Using indexes in json array in PostgreSQL

From Dev

Using secondary indexes to update rows in Cassandra 2.1

From Dev

Delete rows at select indexes from a numpy array

From Dev

deleting empty rows in a cell array

From Dev

Finding the column index given the contents in a cell array

From Dev

Sort Array of Indexes Into Primary Array

From Dev

Numpy: sort rows of an array by rows in another array

From Dev

Sort Array and Store Indexes in a seperate array

From Dev

Given an array of indexes, how can I filter an array in swift?

From Dev

Select given ranges of indexes from source array

From Dev

regular awk - easily sort array indexes to output them in the chosen order

From Dev

how to sort (indexes) of an array to get the original array sorted from the smallest to the biggest value by using those indexes

From Dev

How to sort array indexes from least frequent to most frequent?

From Dev

Selecting a specific number of rows, from a given cell

From Dev

Using indexes in json array in PostgreSQL

From Dev

search an string array using given user and return indexes of the matched string array

From Dev

Indexes in an array of closed intervals of those containing a given number

From Dev

Alphabetical sort in postgresql using indexes.

Related Related

  1. 1

    How to sort elements in array without changing other elements indexes?

  2. 2

    Selecting rows from an HDFStore given list of indexes

  3. 3

    comparing array indexes or multi-dimentional array rows php

  4. 4

    Fastest way to sort an array by a separate array of indices/indexes

  5. 5

    How to get the Sudoku 2D-array index, given its "sub-grid" and "cell-in-the-sub-grid" indexes?

  6. 6

    Unique Rows for a cell array

  7. 7

    Replace elements in an array whose indexes do not match the given indexes

  8. 8

    Combine 2 rows in a cell array

  9. 9

    Find last cell with values using indexes

  10. 10

    How to shuffle the rows in a cell array

  11. 11

    Swift returning the indexes that will sort an array (similar to numpy argsort)

  12. 12

    Using indexes in json array in PostgreSQL

  13. 13

    Using secondary indexes to update rows in Cassandra 2.1

  14. 14

    Delete rows at select indexes from a numpy array

  15. 15

    deleting empty rows in a cell array

  16. 16

    Finding the column index given the contents in a cell array

  17. 17

    Sort Array of Indexes Into Primary Array

  18. 18

    Numpy: sort rows of an array by rows in another array

  19. 19

    Sort Array and Store Indexes in a seperate array

  20. 20

    Given an array of indexes, how can I filter an array in swift?

  21. 21

    Select given ranges of indexes from source array

  22. 22

    regular awk - easily sort array indexes to output them in the chosen order

  23. 23

    how to sort (indexes) of an array to get the original array sorted from the smallest to the biggest value by using those indexes

  24. 24

    How to sort array indexes from least frequent to most frequent?

  25. 25

    Selecting a specific number of rows, from a given cell

  26. 26

    Using indexes in json array in PostgreSQL

  27. 27

    search an string array using given user and return indexes of the matched string array

  28. 28

    Indexes in an array of closed intervals of those containing a given number

  29. 29

    Alphabetical sort in postgresql using indexes.

HotTag

Archive