Delete/remove entire rows and columns containing an element that satisfies a condition (e.g. when the element is an imaginary number)
2 views (last 30 days)
Show older comments
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 Comment
Michael
on 16 Jul 2021
Edited: Walter Roberson
on 16 Jul 2021
You should be able to loop through the columns or rows of the array and check them with isreal:
Accepted Answer
More Answers (1)
Walter Roberson
on 16 Jul 2021
valgood = imag(YourMatrix)==0;
rowmask = all(valgood,2);
colmask = all(valgood,1);
newMatrix = YourMatrix(rowmask, colmask);
0 Comments
See Also
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!