how to use a logical array to set logicals result for entire row.

2 ビュー (過去 30 日間)
Matthew
Matthew 2014 年 6 月 15 日
編集済み: Cedric 2014 年 6 月 15 日
I have a matrix of nrows, with 3 columns. I am looking for an efficient way to use the 3rd column to select which rows i want to include in a new matrix. I want to be able to check if value of 3rd column is greater than 0.2. If it is, then I want to keep that row.
I think i would like to use a logical array, since i want to use that logical array on another variable. I was able to use this
vNormalsTopTest = vNormals>0.2
But, this applies the logical test to all columns. I would like to test the third column and apply that same logical result to the 1st and 2nd columns.
  1 件のコメント
Cedric
Cedric 2014 年 6 月 15 日
編集済み: Cedric 2014 年 6 月 15 日
Good start.
isOkRow = vNormals(:,3) > 0.2 ;
vNormals_reduced = ..
I let you think about the last step. Hint: you could use the vector of logicals isOkRow to index valid rows (logical indexing) of vNormals and something else to index all columns.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by