Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Sorting a cell *different to the usual suspect*?

1 visualizzazione (ultimi 30 giorni)
Tanil
Tanil il 9 Gen 2013
Chiuso: MATLAB Answer Bot il 20 Ago 2021
Hi, I am trying to sort a cell based on another vector. - I have terms in one cell - I have numbers in another corresponding to the terms by their frequency
for example
a = {'the' 'there' 'them' 'they' 'this'}
b = [ 2 8 5 3 6 ]
I would like the output to be so that the order is put into another cell:
there; this; them; they; the
basically I'd like to sort cell(a) by b
Kind Regards, Tanil

Risposte (1)

Walter Roberson
Walter Roberson il 9 Gen 2013
[sortvals, sortorder] = sort(b, 'descend');
c = a(sortorder);

Questa domanda è chiusa.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by