cellfun is slow for lexical sort
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I am trying to lexicogrphically sort a matrix (size - 10000x 1) and i used cellfun, but it is very time consuming. Is there any way to speed up. I tried using for loop but i couldn't get the correct result. My code is
im_dct_num = num2cell(im_dct);
im_dct_temp = cellfun(@num2str,im_dct_num,'UniformOutput',false);
Thanking you in advance
Regards,
Preethi
1 Commento
Risposta accettata
Walter Roberson
il 3 Ott 2013
You should find it faster to use
im_dct_temp = cellstr( num2str( im_dct(:) ) );
but then you need to decide about treating leading or trailing blanks. For example how should
2.00000000
sort relative to
2
? And would your preferred output for 2 be '2' or '2.' or '2.0' ?
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Cell Arrays in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!