Delete rows from matrix and table

Hi Everyone, I want to delete the same rows from a matrix and a table. There is an indicator in the data that I need to remove. I'm setting it up to spit out a matrix that lists the rows that need to be removed. IE: a loop will search for the thing I don't need (data with NaN's) and pull the row number out and I'll end up with [7,400,650,2430]. So in this particular data set I would need to remove those 4 rows. In real life there will be thousands of these. Speed is not a big concern, I only have to run it once. I tried to just replace these rows with zeros but for some reason this isn't working, its probably better I just delete them anyway. Thank you for the suggestions

 採用された回答

Fangjun Jiang
Fangjun Jiang 2018 年 9 月 25 日

1 投票

something like this?
A=magic(10);
rows=[1,3,9];
A(rows,:)=[];

3 件のコメント

madhan ravi
madhan ravi 2018 年 10 月 19 日
+1 concise , congratulation @Fangjun 5000 reputation
Fangjun Jiang
Fangjun Jiang 2018 年 10 月 19 日
Thanks, madhan ravi!
madhan ravi
madhan ravi 2018 年 10 月 19 日
you're welcome MVP :)

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

質問済み:

Max
2018 年 9 月 25 日

コメント済み:

2018 年 10 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by