Path: news.mathworks.com!not-for-mail From: "Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> Newsgroups: comp.soft-sys.matlab Subject: Re: Getting indexes of rows of matrix with more than n repetitions Date: Wed, 6 Jan 2010 19:50:19 +0000 (UTC) Organization: Universität Heidelberg Lines: 25 Message-ID: <hi2phr$5nj$1@fred.mathworks.com> References: <hhudae$4p$1@fred.mathworks.com> <hhuths$led$1@fred.mathworks.com> <hi023t$mtq$1@fred.mathworks.com> <hi1f7i$plv$1@fred.mathworks.com> <hi1g5n$f7i$1@fred.mathworks.com> <hi1ua1$d7e$1@fred.mathworks.com> <hi2300$6dk$1@fred.mathworks.com> <hi24al$3ig$1@fred.mathworks.com> <hi290i$dsp$1@fred.mathworks.com> <hi2fj5$pr2$1@fred.mathworks.com> <hi2gdc$j3u$1@fred.mathworks.com> <hi2im0$fbd$1@fred.mathworks.com> Reply-To: "Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> NNTP-Posting-Host: webapp-05-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1262807419 5875 172.30.248.35 (6 Jan 2010 19:50:19 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Wed, 6 Jan 2010 19:50:19 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 869888 Xref: news.mathworks.com comp.soft-sys.matlab:596971 Dear Matt! > > [foo,foo,foo,goo,goo]=f(); > I know you use this approach, as I do. I was asking why other folks prefer to create a dummy variable in the workspace. The dummy is created with this also, but immediately overwritten! If I have a giantic vector, which nearly fills my memory, and I want to sort it with: [dummy, index] = sort(Array); or [index, index] = sort(Array); in both cases the array is created (any different opinions?)! In the case of cell strings, the sorted array contains shared data copied - fortuantely. But if I never need the sorted array, it would be nice to have a SORTIND, which replies just the index vector. Is anybody willing to publish a MEX wrapper for a quicksort??? That [index] and [index] have the same address is not really surprising. It is the same variable. You do not need a FORMAT DEBUG for that. I failed: Matlab 6.5 has not a sort.c, but sortcellchar.c. This exists in Matlab 7.8 also, but is not documented. Lukily this solves my question for cell strings. The MEX function sortrowsc.c is not an alternative, because it is 6 times slower than SORT if applied to a single column (why?!). If I show "[index, index] = sort(Array)" to a Matlab beginner, I have to explain, that I assume, that the output arguments of a function are assigned from the left to the right. If I show "[dummy, index] = sort(Array)", I do not have to explain anything. Kind regards, Jan BTW. Has the OP tested my try to solve the problem faster than UNIQUE/HISTC/ISMEMBC ?