sortrows based on previous sort results
古いコメントを表示
Here is the thing
I have a large matrix and I need to sort that based on some columns:
B is the large matrix
A=sortrows(B,[1 4 9 10]);%Just a sample input vector
Its OK so far.But then in next step (I'm iterating this function) I will need this:
A=sortrows(B,[1 4 9 10 16]);%Notice I just add a new column to input vector
And same story in next iterations
So my question is how can I use previous sort results in each iteration?
Please consider that the sequence of input vector doesn't matter for me.And if it is possible please give me a note on this sortrows algorithm.
Edit------------ Can someone please explain sortrows algorithm?
Thanks in advance.
2 件のコメント
Image Analyst
2013 年 8 月 19 日
Why do you even need to do the first sort? The second sort will give you the same results regardless of whether you had a sorted or unsorted array to begin with. So doing the first sort is useless. Is there some reason why you needed/wanted to do the first sort?
amir
2013 年 8 月 19 日
採用された回答
その他の回答 (1 件)
Azzi Abdelmalek
2013 年 8 月 19 日
編集済み: Azzi Abdelmalek
2013 年 8 月 19 日
B=sortrows(B,[1 4 9 10])
B=sortrows(B,[1 4 9 10 16])
5 件のコメント
amir
2013 年 8 月 19 日
Azzi Abdelmalek
2013 年 8 月 19 日
This is not obvious to find faster
amir
2013 年 8 月 19 日
Azzi Abdelmalek
2013 年 8 月 19 日
In this case it's true, but it's not what you are asking. Check this case
C=randi(5,20) % Example
A=sortrows(C,[1 4 9 10 16]);
B=sortrows(C,[1 4 9 10]);
B=sortrows(B,16);
isequal(A,B)
A and B are different
amir
2013 年 8 月 19 日
カテゴリ
ヘルプ センター および File Exchange で Shifting and Sorting Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!