How can I sort a matrix according to column IDs and identify same combinations?
古いコメントを表示
Hi,
I edit the question: I have matrix M with six columns and n rows:
M = [HomeID, WorkID, SchoolID, ShopID, timeS, timeP];
for example (lets say it is already sorted):
M = [101, 201, 301, 401, 5.46, 7.83;
101, 201, 301, 401, 3.63, 4.52;
101, 201, 301, 401, 2.785, 2.99;
102, 205, 301, 401, 3.53, 8.5;
102, 205, 301, 402, 3.48, 8.9];
I want to make it in the form of:
M2 = [101, 201, 301, 401, 3.958, 5.113;
102, 205, 301, 401, 3.53, 8.5;
102, 205, 301, 402, 3.48, 8.9];
I want to make calculation for each unique pair of SchoolID-WorkID combination within each unique pair of HomeID-WorkID combination and produce a matrix which will have no multiple Home-Work-School-Shop registers but the unique ones with the average values instead [M2(1,4)=(M(1,4)+M(2,4)+M(3,4))/3].
Thanks,
Iro
6 件のコメント
Matt Kindig
2013 年 5 月 2 日
It is a little confusing how your data is structured. Please provide some sample data, as well as your target output for your sample data. Without seeing your data, it will be a bit difficult to recommend a general solution.
Iro
2013 年 5 月 3 日
José-Luis
2013 年 5 月 3 日
Why is [102,205] not averaged since there are two values for it?
Iro
2013 年 5 月 3 日
Zhang lu
2013 年 5 月 3 日
102, 201, 301, 401, 3.53, 8.5; ? what is it from?
Iro
2013 年 5 月 3 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および 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!