Delete/remove entire rows and columns containing an element that satisfies a condition (e.g. when the element is an imaginary number)
3 ビュー (過去 30 日間)
古いコメントを表示
In an array containing elements that are imaginary numbers, how can I remove the entire row(s) and column(s) containing any of these numbers?
1 件のコメント
Michael
2021 年 7 月 16 日
編集済み: Walter Roberson
2021 年 7 月 16 日
You should be able to loop through the columns or rows of the array and check them with isreal:
採用された回答
その他の回答 (1 件)
Walter Roberson
2021 年 7 月 16 日
valgood = imag(YourMatrix)==0;
rowmask = all(valgood,2);
colmask = all(valgood,1);
newMatrix = YourMatrix(rowmask, colmask);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Operators and Elementary Operations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!