Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Form a matrix from elements of a second matrix

1 回表示 (過去 30 日間)
Shashank
Shashank 2012 年 10 月 22 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Suppose if I have a matrix like this:
Time = [1;2;3;4;5;6;7;8;9;10]
Diameter = [1;2;3;4;5;6;7;8;9;10]
If I want to form two matrices, one for diameters less than 6 and other for diameters greater than 6, how can I do that? I also need times for the corresponding diameters on each matrix.
Thanks.

回答 (1 件)

Matt Fig
Matt Fig 2012 年 10 月 23 日
編集済み: Matt Fig 2012 年 10 月 23 日
Your question is a little unclear, but I think you can get what you want with logical indexing.
idx = Diameter<6; % A logical index.
D1 = Diameter(idx);
T1 = Time(idx);
D2 = Diameter(~idx);
T2 = Time(~idx);

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by