How to separate M*3 matrix by interval of 1

1 回表示 (過去 30 日間)
Yunseo Choi
Yunseo Choi 2018 年 8 月 3 日
コメント済み: Yunseo Choi 2018 年 8 月 3 日
For example, If I have a data like 20*3 data, and define each of column as x y z, how can I separate matrix that the x value is 0<x<1, 1<x<2 , 2<x<3 ... ??
  1 件のコメント
James Tursa
James Tursa 2018 年 8 月 3 日
Please give a short example of input and desired output.

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

採用された回答

Aquatris
Aquatris 2018 年 8 月 3 日
編集済み: Aquatris 2018 年 8 月 3 日
One simple way is;
A = rand(20,3)*10;
for i = 0:9
At{i+1} = A(A(:,1)>i&A(:,1)<i+1,:,:); % Rows of A matrix where first columns
% values are between i and i+1
end
To access the values where i<x<i+1, you call;
At{i+1}
  1 件のコメント
Yunseo Choi
Yunseo Choi 2018 年 8 月 3 日
thanks alot!

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

その他の回答 (1 件)

James Tursa
James Tursa 2018 年 8 月 3 日
E.g., maybe something like this?
data = your 20x3 matrix
x = data(:,1);
result = data( 0<x & x<1 ,:);
  1 件のコメント
Yunseo Choi
Yunseo Choi 2018 年 8 月 3 日
thanks alot!

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

カテゴリ

Help Center および File ExchangeElementary Math についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by