Delete/remove entire rows and columns containing an element that satisfies a condition (e.g. when the element is an imaginary number)
2 次查看(过去 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!