フィルターのクリア

removing spcific numbers from matrix

2 ビュー (過去 30 日間)
mohammed hussein
mohammed hussein 2021 年 2 月 21 日
コメント済み: mohammed hussein 2021 年 2 月 21 日
Hi
i have very large matrix , i would like to remove specific numbers from matrix
for example
i have matrix A=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];
i want to delete B=[11,18]
finally i want
A=[1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 19 20];
just one important point : i have a loop so i want to delete numbers not index and the number that i want to delete it is diffrent in each loop
thank you very much for helping

採用された回答

dpb
dpb 2021 年 2 月 21 日
Don't need (and don't use) loops -- this is MATrix LABoratory, after all! :)
A=A(~ismember(A,B));
or
A=setxor(A,B);
is the more succinct and perhaps(?) a little faster...
  1 件のコメント
mohammed hussein
mohammed hussein 2021 年 2 月 21 日
thank you very much

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by