Eliminating Matrix Elements Which Exceeds Some Threshold with Using idx
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Oz Berk
le 29 Nov 2019
Réponse apportée : JESUS DAVID ARIZA ROYETH
le 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 commentaires
Réponse acceptée
JESUS DAVID ARIZA ROYETH
le 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!