필터 지우기
필터 지우기

cellfun is slow for lexical sort

조회 수: 2 (최근 30일)
Preethi
Preethi 2013년 10월 3일
댓글: Preethi 2013년 10월 4일
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
Walter Roberson
Walter Roberson 2013년 10월 3일
So to check, you would want to sort 1 then 10 to 19 then 2 and so on?

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2013년 10월 3일
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' ?
  댓글 수: 1
Preethi
Preethi 2013년 10월 4일
It is working, speed has improved. If I have to use it for a matrix (ex. 19000 x 64) how do I modify the code?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by