フィルターのクリア

How to sort two columns of a data

2 ビュー (過去 30 日間)
Abin Krishnan
Abin Krishnan 2014 年 2 月 8 日
編集済み: Mischa Kim 2014 年 2 月 8 日
I have an excel sheet with two columns:one showing the diameter of the drops and the other the corresponding velocity.I have to divide the data into three categories - 1/3 with small diameters,1/3 with medium diameter and the last 1/3 with large diameter using MATLAB codes.The velocity should also be grouped accordingly.

採用された回答

Mischa Kim
Mischa Kim 2014 年 2 月 8 日
編集済み: Mischa Kim 2014 年 2 月 8 日
Abin, use sortrows :
A = rand(4,2)
B = sortrows(A)
Once sorted, you can simply access each portion of the sorted matrix B, according to your requirements.
  2 件のコメント
Abin Krishnan
Abin Krishnan 2014 年 2 月 8 日
Thank you. Can you pls tell how to divide the data
Mischa Kim
Mischa Kim 2014 年 2 月 8 日
編集済み: Mischa Kim 2014 年 2 月 8 日
A = rand(13,2);
B = sortrows(A)
[r, c] = size(B);
r_div = floor(r/3);
sec_r = [1 r_div; r_div+1 2*r_div; 2*r_div+1 r];
B_sec2 = B(sec_r(2,1):sec_r(2,2),:)
Some of your data arrays may not be equally dividable into thirds-sections, say, you have 13 measurements. For this case you could, e.g., use the floor command.
r_div = floor(r/3);
which results in the next lower integer of 13/3, which is 4. sec_r is a matrix that holds all the row numbers that "specify" the three sections.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by