Effacer les filtres
Effacer les filtres

Search for an element belonging to a matrix, but not taken into account in the search.

1 vue (au cours des 30 derniers jours)
Good morning. I request your help with a problem I am having. What happens is that I have a matrix called "Tab_nodes" and inside it I am looking for an element that in turn is inside the same table. I am using the following line of code to perform the search:
[rowNod1,colNod1]= find( Tab_nodos ( 1:30, 2:3 ) == Tab_nodos( V_org(celdas,1), 2 ) ) ;
The line of code works quite well, just that I do not want that within the search I contemplated the element that I am looking for, I only want the other elements. I hope you can help me with this mishap. Thank you

Réponses (1)

Walter Roberson
Walter Roberson le 30 Avr 2019
Probably the easiest thing to do is filter it out afterwards.
%column to match has to be 2-1 because the column subset 2:3 is being examined, and column 2
%of the original matrix becomes column 1 of the subset of data
mask = rowNod1 == V_org(celdas,1) && colNod1 == 2-1;
rowNod1(mask) = [];
colNod1(mask) = [];
It is possible to remove the entry before doing the find(), but then you have to turn the Tab_nodos(1:30, 2:3) array into a vector (because arrays cannot have a hole in them) and get linear indexes out of find() and make adjustments afterwards.

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by