行列からある条件を満たした部分以降を抽出する方法

54 visualizaciones (últimos 30 días)
Takahiro Sugahara
Takahiro Sugahara el 30 de Nov. de 2021
Comentada: Takahiro Sugahara el 30 de Nov. de 2021
以下のような行列に対して、2列目の値が1を越えた行から、それ以降を抽出するようなプログラムを作成したく思っています。
A =
0.000 0.02 58.3 1.35
0.001 0.08 69.2 2.30
0.002 0.03 49.6 3.26
0.003 1.62 56.3 1.23
0.004 1.83 78.9 4.36
0.005 1.78 9.64 1.23
... ... ... ...
... ... ... ...
... ... ... ...
ある条件を満たした行や列を抽出する方法はいくつか拝見しましたが、ある条件を満たした行以降を抽出する方法がわかりません。
初歩的な質問で恐縮ですが、ご教示いただきたく思います。

Respuestas (1)

Akira Agata
Akira Agata el 30 de Nov. de 2021
find 関数を使う下記の方法ではいかがでしょうか?
% A の2列目が >= 1 となる最初の行番号を pt として取得
pt = find(A(:,2) >= 1, 1);
% pt行目から最後までの行を配列 B として保存
B = A(pt:end, :);
  1 comentario
Takahiro Sugahara
Takahiro Sugahara el 30 de Nov. de 2021
やりたいことが出来ました。ありがとうございます。

Iniciar sesión para comentar.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!