Eliminating Matrix Elements Which Exceeds Some Threshold with Using idx
13 views (last 30 days)
Show older comments
Oz Berk
on 29 Nov 2019
Answered: JESUS DAVID ARIZA ROYETH
on 29 Nov 2019
I am working on a Radon transform algorithm, in my code i have a set of x,y values and i wanted to eliminate the x,y values which exceeds some certain values like -2 and 2 for example. For this purpose, i am using the code below but i couldn't get how it works. Is there anyone who can explain to me?
idx=any(A<-M/2 | A>M/2,2);
out=A(idx,:);
A(idx,:)=[];
Thanks in advance.
0 Comments
Accepted Answer
JESUS DAVID ARIZA ROYETH
on 29 Nov 2019
A is a Matrix of m rows by n columns, therefore, idx is going to be a logical vector of m rows by 1 column, if any element in the row of A is less than -M / 2 or greater than M / 2 then in that row the idx value will be 1 otherwise it will be 0.
in out those rows of A that were positive in idx are going to be saved and from those rows we want to get all the columns, and after that in those same rows that were 1 with A (idx,:) = []; what is done is to eliminate them and have a new Matrix of A without those rows.
0 Comments
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!