using function to remove elements from a large matrix

I need to code for a matrix in which the rows are removed given thier value in a certain column is not of desire to me. eg, I want to keep the numbers 1 2 3 and 11 and 12 but not 4 5 6 or 13 14 etc.

3 件のコメント

Malik Khan
Malik Khan 2019 年 12 月 25 日
It does not have to be a function.
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 12 月 25 日
Have you tried, please show your efforts?
Malik Khan
Malik Khan 2019 年 12 月 25 日
I have not attempted this yet because I have no idea where to start

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

 採用された回答

the cyclist
the cyclist 2019 年 12 月 25 日
編集済み: the cyclist 2019 年 12 月 25 日

0 投票

idxToKeep = ismember(M(:,2),[1,2,3,11,12]);
M = M(idxToKeep,:);

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

質問済み:

2019 年 12 月 25 日

編集済み:

2020 年 1 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by